[Solved] Hiding empty content block--dupe block names error?

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
User avatar
Samarama
New Member
New Member
Posts: 5
Joined: Wed Sep 01, 2010 11:11 pm
Location: NE Ohio

[Solved] Hiding empty content block--dupe block names error?

Post by Samarama »

Using CMSms 1.10.3, new install, no extra modules yet.

Trying to set up a 2/3-column template where the right-hand column (sidebar_right) only appears if there's content. I've got this basic logic, picked up from some similar questions in this forum:

{capture assign='testvar'}{content block='contents-rt' label='RIGHT Sidebar Content (optional)'}{/capture}
{if isset($testvar) && !empty($testvar)}
<div id="main" class="grid_6">
<div id="contentmain">
{content label="MAIN Content Area"}
</div>
</div>
<div id="sidebar_right" class="grid_3 omega">
<div id="contentright">
{$testvar}
</div>
</div>
{else}
<div id="main" class="grid_9 omega">
<div id="contentmain">
{content label="MAIN Content Area"}
</div>
</div>
{/if}

So basically the main content area should get wider if the right column has no content. Right column just would not appear at all.

When I try to add a new content page with this template, I get this:

An error occurred parsing content blocks (perhaps duplicated block names)

Also, none of the content areas are showing on the New Content page?

Seems like I am really close, but missing some important detail here. Suggestions, pointers, ideas anyone?

Thanks
Last edited by Samarama on Fri Feb 24, 2012 5:46 pm, edited 1 time in total.
Jos
Support Guru
Support Guru
Posts: 4019
Joined: Wed Sep 05, 2007 8:03 pm
Location: The Netherlands

Re: Hiding empty content block -- duplicate block names erro

Post by Jos »

Replace this

Code: Select all

{capture assign='testvar'}{content block='contents-rt' label='RIGHT Sidebar Content (optional)'}{/capture}
with this

Code: Select all

{content block='contents-rt' label='RIGHT Sidebar Content (optional)' assign='testvar'}
{content label="MAIN Content Area" assign='maincontent'}
and the two occurrences of {content label="MAIN Content Area"} should then be replaced by

Code: Select all

{$maincontent}
Wishbone
Power Poster
Power Poster
Posts: 1368
Joined: Tue Dec 23, 2008 8:39 pm

Re: Hiding empty content block -- duplicate block names erro

Post by Wishbone »

EDIT: Jos beat me to it. :)

Regardless of your logic, you must only have one content block of a given name. (including {content} without block= )

Also, you don't need {capture} around your block.

Try:

Code: Select all

{content label="MAIN Content Area" assign="main_content"}
{content block='contents-rt' label='RIGHT Sidebar Content (optional)' assign='testvar'}
{if isset($testvar) && !empty($testvar)}
<div id="main" class="grid_6">
<div id="contentmain">
{$main_content}
</div>
</div>
<div id="sidebar_right" class="grid_3 omega">
<div id="contentright">
{$testvar}
</div>
</div>
{else}
<div id="main" class="grid_9 omega">
<div id="contentmain">
{$main_content}
</div>
</div>
{/if}
I usually use assign= , so the content blocks, when editing, show up where I want, regardless of the order that they appear in the HTML.
User avatar
Samarama
New Member
New Member
Posts: 5
Joined: Wed Sep 01, 2010 11:11 pm
Location: NE Ohio

Re: Hiding empty content block -- duplicate block names erro

Post by Samarama »

Thanks so much for quick response! This works perfectly, I'm marking it solved.

Wishbone:
Regardless of your logic, you must only have one content block of a given name. (including {content} without block= )

Thanks for the explanation, this is the part I wouldn't have figured out on my own.
Post Reply

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