Modifying module or tag output without getting hands (too) dirty
Posted: Mon Jul 24, 2006 10:37 pm
Hi
It's a bit smelly but I had a 'quick win' requirement to munge the output from the menumanager into a number of fixed width columns. I've only ever used Smarty at it's simplest level so all I had to go on was the documentation on their website.
Long story short; the way I ended up doing this was by using a combination of Smarty's {capture} tag and Smarty modifiers, thus:
1) Embed code into template, wrapping the tag that you want to play with in the {capture} tags with the 'name' being the variable that collects the output. Then reference the variable but immediately pass the variable to a smarty modifer function, in this case menu_munge.
{capture name=specialMenu}
{cms_module module='menumanager' start_level='2'}
{/capture}
{$smarty.capture.specialMenu|menu_munge}
2) Create the modifer function in /lib/smarty/plugins/ called modifer.menu_munge.php
3) Fill it with something:
(.*?)\/",$string,$foo);
print_r($foo);
}
?>
Obviously that doesn't do much but you can see now that I have something to play with.
YMMV, works for me, etc
It's a bit smelly but I had a 'quick win' requirement to munge the output from the menumanager into a number of fixed width columns. I've only ever used Smarty at it's simplest level so all I had to go on was the documentation on their website.
Long story short; the way I ended up doing this was by using a combination of Smarty's {capture} tag and Smarty modifiers, thus:
1) Embed code into template, wrapping the tag that you want to play with in the {capture} tags with the 'name' being the variable that collects the output. Then reference the variable but immediately pass the variable to a smarty modifer function, in this case menu_munge.
{capture name=specialMenu}
{cms_module module='menumanager' start_level='2'}
{/capture}
{$smarty.capture.specialMenu|menu_munge}
2) Create the modifer function in /lib/smarty/plugins/ called modifer.menu_munge.php
3) Fill it with something:
(.*?)\/",$string,$foo);
print_r($foo);
}
?>
Obviously that doesn't do much but you can see now that I have something to play with.
YMMV, works for me, etc