Page 1 of 1

Swapping a single div in a template (SOLVED)

Posted: Sat Jul 12, 2014 2:30 pm
by Dave59
Hello
Would appreciate some advice please!
I am using 1.11.10. and can not solve what seems a simple problem.
http://www.entwurf.plasma-treating.com.
I am at the start of this and am simply getting the basic functions set up. It is still using the sample content from the install.
I have a level 1 top horizontal nav.
When there are children these appear in a vertical nav. This hides where there are no children.

Code: Select all

{menu start_level='2' assign='menu_there'}
{if $menu_there}
   <div id="submenu">
      <h3>Submenu</h3>
      {menu start_level='2'}
   </div>
{/if}
I also have a news/product focus on the right. This is not global as each instance will be different.
This appears only when it contains content
So I normally have either 25% side nav and 75% mian content, or 75% main content and 25% news across my page.
All works well until I get a side nav, main content and news.
All I want to do is switch the CSS width for main content to say 50% minus the gutters.
Tried having a nested template as detailed in http://www.i-do-this.com/blog/Smarty-te ... -Simple/57 . But this just throws up “duplicate content block: content_en” on applying the template as soon as I add

Code: Select all

{block name='small'}
    {content assign='main_content'}
{/block}
above the head section? So I can't apply this.
I don't even have one "content_en".
The idea was simply a div called smalllcontent in an extension template to swap out the div widecontent to pick up the different CSS.
I have set the background of the right hand column to red just to make it easy to see what is happening when all three are active.
The links “Home”, “How CMSMS works” and “default templates” show up the three conditions.
I want to keep the templates to a min as the site will be translated to Chinese when it is up and running so I don't want to have a second template for this small change.
I will be setting up mobile formatting etc and adding design later.
Thanks
Dave

Re: Swapping a single div in a template

Posted: Sat Jul 12, 2014 2:38 pm
by Jo Morg
Dave59 wrote:I don't even have one "content_en".
Well... the error message is a bit misleading, but content_en means the default {content} tag.The error means you tried to use two default {content} tags on the same template.
http://docs.cmsmadesimple.org/tags/core/content

I don't know about the rest and your link is not reachable, so I can't help you there.

Re: Swapping a single div in a template

Posted: Sat Jul 12, 2014 3:07 pm
by Dave59
Hi
Have I made a typing error
http://entwurf.plasma-treating.com/
This link is copied directly.
As for the duplicated content this only come when I add

Code: Select all

{block name='small'}
    {content assign='main_content'}
{/block}
Sorry

Re: Swapping a single div in a template

Posted: Sat Jul 12, 2014 3:21 pm
by Jo Morg
Dave59 wrote: As for the duplicated content this only come when I add

Code: Select all

{block name='small'}
    {content assign='main_content'}
{/block}
Then you need to remove the original {content} tag and replace it by {$main_content}
as it can be confirmed by looking at the template from the article.

Re: Swapping a single div in a template

Posted: Sat Jul 12, 2014 4:42 pm
by Dave59
OK Thanks.
I will see if I can sort this tomorrow.
I was trying to apply this to widecontent. Changing the code to this stops the duplicated content message. :-[
I have been struggling with this too long today. I will set this to solved and try to get the nested template to work in the morning.
Thanks for your quick help.
I have been away from CMSMS for a while now (Not with another CMS) and it is nice to see things are still running well.
Thank you

Re: Swapping a single div in a template (SOLVED)

Posted: Sat Jul 19, 2014 9:19 am
by Dave59
The solution I went for. Not the most elegante, but good enough.
What I did in the end is install Advanced content.
I used

Code: Select all

{content block=wide label="wide"  assign=bar}
{if $bar}
<div id="widecontent" >
{$bar}</div>
{/if}
{content block=small label="small"  assign=bar}
{if $bar}
<div id="smallcontent" >
{$bar}</div>
{/if}
Did the same for news and side menu. Except that side menu was set only to appear if the main nav had children.
Obviously write the CSS for wide and smallcontent to suite
Under content type select advanced content before you edit the page.
The you have drop downs in my WYSIWYG editor and could select the content block to put my content in.
If I have a page with
Content and news columns or Nav and content I put my text in wide.
If I had Nav, Content and news columns I put it in small.
Note:
Put the div tag inside the { if$bar } so that they are not loaded or it will disrupt your layout.
This is just in case anyone else is stuck with this or something similar.
Hope it helps and thanks for replying to my question Jo Morg.