Page 1 of 1

[Solved] How to Make Global Content Blocks Dynamic?

Posted: Tue Feb 05, 2008 1:05 am
by applejack
Hi

I am trying to create the reference to global content blocks on the fly using the menu manger to get the parent name of the page i.e.

{global_content name="{menu template='parent' start_level='2' number_of_levels='1'}"}

but it give a Smarty error.

If anyone knows how to generate global content block references dynamically please let me know as this would be very useful for cutting down on the number of templates required.

If anyone knows how to pass Smarty values to Javascript variables in a template then I might be able to use that.

Thanks in advance.

Re: How to Make Global Content Blocks Dynamic?

Posted: Tue Feb 05, 2008 1:14 am
by calguy1000
You can't nest { and } things in smarty calls.

look at http://smarty.php.net/manual/en

But other than that:

1) Install the CGSimpleSmarty module

2) {global_content name="$cgsimple->get_parent_alias()"}

Re: How to Make Global Content Blocks Dynamic?

Posted: Tue Feb 05, 2008 2:10 am
by applejack
Which is why {global_content name="$cgsimple->get_parent_alias()"} also doesn't work as the call to cgsimple also needs to be surrounded by Smarty tags {$cgsimple->get_parent_alias()}

C'est la vie.

Re: How to Make Global Content Blocks Dynamic?

Posted: Tue Feb 05, 2008 8:01 am
by alby
applejack wrote: Which is why {global_content name="$cgsimple->get_parent_alias()"} also doesn't work as the call to cgsimple also needs to be surrounded by Smarty tags {$cgsimple->get_parent_alias()}
No double {}, {$cgsimple->get_parent_alias()} it's correct

If {global_content name="$cgsimple->get_parent_alias()"} doesn't work (sometimes " don't work) try without (") or with backtick (`) sintax:
{global_content name=$cgsimple->get_parent_alias()}
{global_content name=`$cgsimple->get_parent_alias()`}

Alby

Re: How to Make Global Content Blocks Dynamic?

Posted: Tue Feb 05, 2008 11:35 am
by applejack
Alby

Thanks very much for that worked without the quotes.