|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
mystrymaster Smarty Rookie
Joined: 31 Oct 2003 Posts: 17
|
Posted: Tue Nov 04, 2003 6:58 pm Post subject: getting the first letter of a variable |
|
|
so I need to be able to get the first letter of a smarty assigned variable in my template to be able to generate a list of letters across the top for targated hrefs in the page
I know how to get them in php however I don't know how to get smarty to out put the <a name='letterHere'></a> Only on the first instance of the letter.
Is there a way that I can get the first letter of a smarty assigned variable? |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Tue Nov 04, 2003 7:59 pm Post subject: |
|
|
the absolute simplest way to do so would be to use the PHP substr function as a modifier:
{$var|substr:0:1}
You might consider writing a custom modifier to pacakge this in a more straightforward manner, perhaps {$var|firstletter}
HTH |
|
Back to top |
|
mystrymaster Smarty Rookie
Joined: 31 Oct 2003 Posts: 17
|
Posted: Wed Nov 05, 2003 8:20 pm Post subject: |
|
|
thanks boots works perfectly - maybe after I get a little more comfortable with smarty I will right a modifier for it. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|