Page 1 of 1
replace content block value by a smarty variable?
Posted: Sun Mar 31, 2013 8:33 pm
by Manuzzi
I want to replace the value of the content block "myvalue" by a variable. Is that possible?
I tried something like this:
{assign var="i" value="1"}
{assign var="blockname" value="movie_{$i}"}
{content block="$blockname" assign="movie_$i" oneline="true"}
But "$blockname", {$blockname} or "`$blockname`" does not give the desired result.
I want to use this code in a while-loop to get a next content block if the last one is filled with content
Re: replace content block value by a smarty variable?
Posted: Sun Mar 31, 2013 8:50 pm
by Rolf
Re: replace content block value by a smarty variable?
Posted: Sun Mar 31, 2013 8:56 pm
by Jo Morg
Manuzzi wrote:I want to use this code in a while-loop to get a next content block if the last one is filled with content
I'm not sure you can do it that way at all: I think that Content Blocks need to be defined and not a result of template logic... , but besides that the syntax is wrong...
Maybe, if at all possible, this could work...
Code: Select all
{assign var="i" value="1"}
{assign var="blockname" value="movie_{$i}"}
{content block=$blockname assign="movie_`$i`" oneline="true"}
Re: replace content block value by a smarty variable?
Posted: Sun Mar 31, 2013 9:01 pm
by calguy1000
wont work. Content blocks have to be defined as a NAME in the template. Because the block name is used in the database.
if you want numerous blocks in a template, you will need to write a module that takes advantage of some of the advanced functions of the module API.
Re: replace content block value by a smarty variable?
Posted: Mon Apr 01, 2013 11:48 am
by Manuzzi
Thank you all for the replies.
I will leave the idea and just get back to my original setup defining a fixed amount of content blocks.