[solved] Smarty in Smarty

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

[solved] Smarty in Smarty

Post 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}
Last edited by Anonymous on Tue May 13, 2008 7:28 pm, edited 1 time in total.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: Smarty in Smarty

Post 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.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: Smarty in Smarty

Post by Dr.CSS »

Thanks it worked great...
Post Reply

Return to “The Lounge”