[Solved]Use custom content block twice?

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
vinyl
Forum Members
Forum Members
Posts: 149
Joined: Mon Jul 13, 2009 8:18 pm

[Solved]Use custom content block twice?

Post 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?
Last edited by vinyl on Fri Nov 29, 2013 9:10 pm, edited 1 time in total.
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1974
Joined: Mon Jan 29, 2007 4:47 pm

Re: Use custom content block twice?

Post 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
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
vinyl
Forum Members
Forum Members
Posts: 149
Joined: Mon Jul 13, 2009 8:18 pm

Re: Use custom content block twice?

Post by vinyl »

Great! Thanks for this solution. I knew it was possible, just couldn't find how..
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1974
Joined: Mon Jan 29, 2007 4:47 pm

Re: Use custom content block twice?

Post by Jo Morg »

Glad I could help. Would you please add [Solved] to the beginning of the subject title?
Thanks :)
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
Post Reply

Return to “The Lounge”