![]() |
Truncating to the FIRST Character in a variable
trying to modify the customer reviews so that it doesn't automatically populate the name with the full name and email address of the customer.
Removing the email address was easy enough but now I am trying to have it default to just their first initial and last name .. or first name and last initial but I do not know how to modify the variable to only display the first character. Code:
{if $login ne ""} any ideas? Thanks! |
Take a look at the customer/main/products.tpl note the truncate command smarty has in there to reduce the short description to 300 chars, you can use the same code to accomplish what you want here.
|
the problem is that I need the FIRST character .. so if a name is 8 characyers long I need to use the FIRST one.
FirstName LastName = F. LastName here is what I am in the progress of working on that seems to work. It's not pretty but seems to work for the most part Code:
{assign var="count1" value=$customer_info.firstname|count_characters:true} |
try:
Code:
{if $login ne ""} This will work on the product reviews. |
ok, that was what it looked like in the example that Groovico pointed me to but thought that wouldn't work.
I was all over smarty.php.net and went back after your post. I guess what threw me was the description of what the parameter TRUE did. Quote:
Thanks!!!, wish I wouldn't have spent as much time as I did on figuring THAT one out though :) |
i get it now. by setting it to TURE then it does the WORD and since most people only use 1 first name then this works. But if someone uses a 2 word first name then it will only truncate the last one .. right?
like: Lisa Marie Smith = Lisa M. Smith Right?? |
Best way of working stuff like that out is simply to do quick tests
{$customer_info.firstname|truncate:2:".":true} {$customer_info.firstname|truncate:2:".":False} And just view the effects |
All times are GMT -8. The time now is 12:58 AM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.