Page 1 of 1

[Solved]Use custom content block twice?

Posted: Thu Nov 28, 2013 9:37 pm
by vinyl
Is it possible to place the content of the same content block twice in a template?

I'm developing a mobile site for a client and want to re-use as much as possible.

Some pages use the GBFilepicker module to add an image for the page. I would like to show that image in the mobile site and the normal site.

Because I divide my code using {mobiledetect} and an if else statement the content for the page is separated, therefor I like the call the same custom content block twice. Any possibilities?

Re: Use custom content block twice?

Posted: Fri Nov 29, 2013 7:54 am
by Jo Morg

Code: Select all

....
   {* Assign the main Content block to a string *}
   {content assign='maincontent' label='My content block'}
   {* Create a second content block! *}
   {content block='second_content' assign='second_content' label='My second content block'} 

........


   <div id="content">
      <h2>{title}</h2> <!-- Title of the page -->
      {$maincontent} <!-- Page content from string -->
 
      {if $second_content} <!-- Only show second content block when it has some content -->
         <h3>Second Content Block</h3>
         {$second_content}
      {/if}
   </div> 

............



      {if $second_content} <!-- Only show second content block when it has some content -->
         <h3>Second Content Block</h3>
         {$second_content}
      {/if}


.......

etc...
http://docs.cmsmadesimple.org/layout/ex ... e-template

Re: Use custom content block twice?

Posted: Fri Nov 29, 2013 1:22 pm
by vinyl
Great! Thanks for this solution. I knew it was possible, just couldn't find how..

Re: Use custom content block twice?

Posted: Fri Nov 29, 2013 1:59 pm
by Jo Morg
Glad I could help. Would you please add [Solved] to the beginning of the subject title?
Thanks :)