 |
Smarty
The discussions here are for Smarty, a template engine for the PHP programming language. Dedicated server web hosting provided by Guru-host.eu. |
| View previous topic :: View next topic |
| Author |
Message |
bimal Smarty Elite

Joined: 19 Apr 2007 Posts: 419 Location: Kathmandu, Nepal
|
Posted: Sat Nov 21, 2009 12:43 am Post subject: initcap modifier |
|
|
When we assume, that a name is stored in lowercase, a small modifier can fix the display. (This is a info only post.) Save the file: modifier.initcap.php into your plugins folder as:
modifier.initcap.php
| Code: | /**
* Capitalizes all first letters in a word.
*/
function smarty_modifier_initcap($string='')
{
$string = ucwords($string);
return($string);
} |
And usage example:
Now, it can look like SQL's INITCAP() function. You can extend this modifier to extra process and validate the name, like removing extra spaces, etc.
However, a very quick and lazy processing does not need a separate modifier. You can call php's function directly, as:
_________________ Skype: pbimal
To hire instantly as a freelancer - https://www.odesk.com/o/profiles/users/_~~657b70cc7f2c616a/
Visit my website - http://bimal.org.np/ for more articles
800+ screenshots to learn about website mistakes: http://mistakes.sanjaal.com/ |
|
| 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
|