|
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 |
spunkymungbeans Smarty Regular
Joined: 14 Mar 2005 Posts: 49
|
Posted: Sat Aug 19, 2006 3:05 pm Post subject: Including function in {if} statement |
|
|
I have the following which is causing me grief:
Code: |
<?php
if (CountModules('m1') >= 1 OR CountModules('m3') >= 1 ) {
etc
}
?>
|
I have created a plugin to return the CountModules value, eg:
{CountModules position='m1'}
But how do I include the results in an if statement? _________________ Leonie |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Sat Aug 19, 2006 9:47 pm Post subject: |
|
|
Create a modifier rather than a function plugin. |
|
Back to top |
|
spunkymungbeans Smarty Regular
Joined: 14 Mar 2005 Posts: 49
|
Posted: Sun Aug 20, 2006 2:50 am Post subject: |
|
|
Thanks. I've done this:
Code: |
function smarty_modifier_mosCountModules ($position) {
return mosCountModules($position);
}
|
called thus:
Code: |
{if ("m1"|mosCountModules gte 1) OR ("m3"|mosCountModules gte 1 ) }
etc...
|
_________________ Leonie |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Sun Aug 20, 2006 11:09 pm Post subject: |
|
|
It seems that mosCountModules is already defined as a normal PHP function. As long as you don't use Smarty's security features, it should be available automatically both as a modifier (without writing a plugin wrapper) and as a valid function that can be used in if statements. |
|
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
|