| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | User manuals | Login |
"Firstname, Lastname": Can you count characters? | |||
|
|
Thread Tools | Search this Thread |
#1
|
|||||||||
|
|||||||||
"Firstname, Lastname": Can you count characters?
Hi All,
I have a bar along the top of my site that tells you who's logged in. Code:
However, I only have a limited amount of space to fit a name in, before it starts overlapping something else. I wondered if there was a way to count how many characters are in the person's name - If it's over a certain amount, only display their first name? Thanks in advance, Jean
__________________
4.2.3 X-Cart Gold BCSE Address Book | XCartMods QuickFind | X-RMA | X-Offers -------[installed]----------------------[installed]--------------[installed]----[installed]-- 5: in development |
|||||||||
#2
|
|||||||
|
|||||||
Re: "Firstname, Lastname": Can you count characters?
This will truncate the greeting at or before 30 characters at a word boundary.
{$smarty.cookies.GreetingCookie|replace:"\'":"'"|t runcate:30:"":true} See http://www.smarty.net/manual/en/language.modifier.truncate.php for details on the truncate modifier.
__________________
Manuka Bay Company X-Cart Version 4.0.19 [Linux] UGG Boots and other fine sheepskin products http://www.snowriver.com |
|||||||
#3
|
|||||||||
|
|||||||||
Re: "Firstname, Lastname": Can you count characters?
Hi Ralph,
Thank you very much for the response, However, I don't really want to truncate, as such. I would rather count how many characters there are and only display the first name, if the total is greater than a given value. So, if someone's name was 'John Smith', that would display in full. But if someone else's name was 'Hubert Wolfeschlegelsteinhausenbergerdorff', It would only display 'Hubert'. (If the characeter limit was 30.) I hope this makes sense?
__________________
4.2.3 X-Cart Gold BCSE Address Book | XCartMods QuickFind | X-RMA | X-Offers -------[installed]----------------------[installed]--------------[installed]----[installed]-- 5: in development |
|||||||||
#4
|
|||||||||
|
|||||||||
Re: "Firstname, Lastname": Can you count characters?
it should do this as it will only truncate at a word boundary, so the gap between first and last name? if the first and last is 30 or below (for example), it will display both, if the first and last name is larger than 30 it will truncate at the boundary, and only display the first name,
hth
__________________
X-Cart version 5 (Previously 3.5-4) Previous Versions included BCSE Reward Points Mod Altered Cart On Sale Mod Wordpress Plugin Please don't PM me for support. I help where I can on the forum and your question will more likely be answered there. Shout me a Coffee! |
|||||||||
#5
|
|||||||
|
|||||||
Re: "Firstname, Lastname": Can you count characters?
That's why I set the flag to truncate on a word boundary so it would truncate the whole last name if its over 30 characters. The only problem you should run into is a long first name with a two part last name like Robertthegreatestmanalive Van Buren which will display as Robertthegreatestmanalive Van or first names longer than you have room for.
To do exactly what you want you'll need to modify the php code in a couple of places where the cookie gets set - login and register I believe, search for "greet" to find the spots. The cookie will only get updated when customers login so it may take a while before it gets propagated to all users. Or you could change the cookie name and start all users over with no greeting.
__________________
Manuka Bay Company X-Cart Version 4.0.19 [Linux] UGG Boots and other fine sheepskin products http://www.snowriver.com |
|||||||
#6
|
|||||||||
|
|||||||||
Re: "Firstname, Lastname": Can you count characters?
Ooops - Completely my mistake - Sorry Ralph!
In that case - That's wonderful, thank you ever-so! I shall sort that out now and report back! Thanks, both - Really appreciate it!!
__________________
4.2.3 X-Cart Gold BCSE Address Book | XCartMods QuickFind | X-RMA | X-Offers -------[installed]----------------------[installed]--------------[installed]----[installed]-- 5: in development |
|||||||||
#7
|
|||||||||
|
|||||||||
Re: "Firstname, Lastname": Can you count characters?
I had to take the "true" off the end, because it was truncating exactly at 30?
Now works brilliantly: Trevor Test: http://i16.photobucket.com/albums/b49/BeanJardo/Work/trevortest.jpg Trish Wolfeschlegelsteinhausenberger: http://i16.photobucket.com/albums/b49/BeanJardo/Work/trish.jpg Hurrah! Thanks both - Very happy!
__________________
4.2.3 X-Cart Gold BCSE Address Book | XCartMods QuickFind | X-RMA | X-Offers -------[installed]----------------------[installed]--------------[installed]----[installed]-- 5: in development |
|||||||||
#8
|
|||||||
|
|||||||
Re: "Firstname, Lastname": Can you count characters?
Yep, I got the idea right but the details wrong. I forgot the default for truncate was a word boundary and setting the flag to true was for exact length truncation. Gotta read the doc a little closer next time. Glad its working.
__________________
Manuka Bay Company X-Cart Version 4.0.19 [Linux] UGG Boots and other fine sheepskin products http://www.snowriver.com |
|||||||
|
|||
X-Cart forums © 2001-2020
|