replace content block value by a smarty variable?

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
Manuzzi
Forum Members
Forum Members
Posts: 17
Joined: Mon Aug 16, 2010 8:56 am

replace content block value by a smarty variable?

Post 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
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Contact:

Re: replace content block value by a smarty variable?

Post by Rolf »

- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1974
Joined: Mon Jan 29, 2007 4:47 pm

Re: replace content block value by a smarty variable?

Post 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"}
 
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: replace content block value by a smarty variable?

Post 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.
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.
Manuzzi
Forum Members
Forum Members
Posts: 17
Joined: Mon Aug 16, 2010 8:56 am

Re: replace content block value by a smarty variable?

Post 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.
Post Reply

Return to “The Lounge”