Page 1 of 1
add multiple content blocks from editing interface
Posted: Wed Mar 07, 2012 8:59 pm
by lisa89
Hi everyone,
I have a page which will contain multiple blocks of content representing a list contained inside <div class="item"></div>.
In the template I can put
Code: Select all
<div class="item">
{content}
</div>
<div class="item">
{content block="2"}
</div>
<div class="item">
{content block="3"}
</div>
however I want the editor to be able to add a new content blocks without changing the template above, consider that what I represented as <div class="item"></div> could be much more intricate and I don't want the editor to forget some closing <div>which would mess the html.
How can I implement this?
Hope I have been clear enough, cheers.
Re: add multiple content blocks from editing interface
Posted: Wed Mar 07, 2012 9:19 pm
by mcDavid
You can assign content blocks to a variable, and use that to check if the block is actually filled in.
Code: Select all
{content block='block1' assign='block1'}
{if !empty($block1)}
<div> {$block1} </div>
{/if}
And so on for as many blocks as you want.
-edit-
I see you're talking about "items", wouldn't you be better off using a module like News or Products or something?
Re: add multiple content blocks from editing interface
Posted: Thu Mar 08, 2012 12:16 pm
by lisa89
thank you mcDavid your solution appeared to be the right solution, however I still miss a bit.
I tried using your solution with the template below:
Code: Select all
{content block="optional product1" assign='product1'}
{if !empty($product1)}
<div class="product1">{content block="optional product1" oneline="true"}</div>
{/if}
{content block="optional product2" assign='product2'}
{if !empty($product2)}
<div class="product2">{content block="optional product2" oneline="true"}</div>
{/if}
{content block="optional product3" assign='product3'}
{if !empty($product3)}
<div class="product3">{content block="optional product3" oneline="true"}</div>
{/if}
However I still have to put N blocks in my template while I'd like the blocks to increment to block2,block3,block4 automatically.
Even worse when editing the page the user will be shown all N blocks, while he should only see the ones which have content plus an empty one to insert new content.
Hope it's clear what I mean...
Thank you very much!
Re: add multiple content blocks from editing interface
Posted: Thu Mar 08, 2012 7:28 pm
by uniqu3
Use a Module instead that can achieve your task, there is currently no way to have undifined number of block.
Look at ListItExtended module, this might get you to your goal.