Page 1 of 1

[solved] Smarty in Smarty

Posted: Mon May 12, 2008 11:44 pm
by Dr.CSS
I wasn't sure where to put this so here goes, and yes I looked all over the net, php.net, php wiki, smarty etc. etc. tried taking out {} front back sideways, use [], and about 20 other ways to write it...

I have a spot in my template where I need to change a phone # by what section/parent they are under and I'm able to get the parent_page_alias to use it as a class on a div but I can't use it for a custom content block like so...

{global_content name="{nextup assign="parent_page_alias"}{$parent_page_alias}num"}

nextup is the name of a UDT I made for the parent alias and it works in the class call, but not inside of another Smarty tag...

This is how I do it in the class call...

class="{nextup assign="parent_page_alias"}{$parent_page_alias}

Re: Smarty in Smarty

Posted: Tue May 13, 2008 12:37 am
by calguy1000
You can't nest smarty tags.... smarty is smart, but not THAT smart.

The capture smarty plugin (it's in the smarty docs) allow you to capture anything between {capture assign='somevar'}whatever code I want including {$some_smarty_variable}{/capture} into a single smarty variable called (in this case) somevar.

so In your cased I'd do something like:

{capture assign='parent_page_alias'}{nextup}num{/capture}
{global_content name=$parent_page_alias}

btw... check out the CGSimpleSmarty Module, it has a function to get the parent page alias already.

Re: Smarty in Smarty

Posted: Tue May 13, 2008 7:28 pm
by Dr.CSS
Thanks it worked great...