|
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 |
bimal Smarty Elite
Joined: 19 Apr 2007 Posts: 423
|
Posted: Thu Oct 28, 2010 1:01 pm Post subject: Call static functions without assiging an object |
|
|
It is possible to write fairly complex Smarty Template tags. The one that saved my time was the ability to call static methods, without assigning any object.
Code: |
{tools::random_text(6)}
{tools::random_text($length)}
|
and a real life example is:
Code: | <a href="results.php?random={tools::random_text($length)}">Results</a> | which helps to force reloading the results.php page, without caching in the browser.
Much interesting is that $length is a Smarty variable, and not a regular PHP variable. But the compiled files produce results as expected.
tools is a class, having random_text() as static function. |
|
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
|