add multiple content blocks from editing interface

For discussion and questions related to CMS Specific templates and stylesheets (CSS), and themes. or layout issues. This is not a place for generic "I don't know CSS issues"
Post Reply
lisa89
New Member
New Member
Posts: 3
Joined: Sat Dec 10, 2011 11:06 am

add multiple content blocks from editing interface

Post 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.
mcDavid
Power Poster
Power Poster
Posts: 377
Joined: Tue Mar 31, 2009 8:45 pm

Re: add multiple content blocks from editing interface

Post 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?
lisa89
New Member
New Member
Posts: 3
Joined: Sat Dec 10, 2011 11:06 am

Re: add multiple content blocks from editing interface

Post 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!
uniqu3

Re: add multiple content blocks from editing interface

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

Return to “Layout and Design (CSS & HTML)”