Repeating Sections

Lots of website pages consist of a number of similar sections, especially sites built around grid systems such as Foundation or Bootstrap – e.g. a repeating number of blocks containing an image, heading and a content section. In SiempreCMS rather than having to use child nodes, which editors find confusing, you can define sections.

 

Defining a Section in the Back office

Firstly create your entities (e.g. Heading, Image, SectionText). Then click the Create New Section button at the bottom of the page. This creates a new section with a new ID. You can then set this section ID in the drop down on each of the entities you wish to group together in repeating sections.

 

Setting up the Section

Template Code

Next you need to put tell the template the section ID and create the repeating HTML mark-up. This will then be looped like a for loop. NOTE replace the ‘1’ in @Page.Sections(1) with your section ID.

 

{|@foreach(Section in @Page.Sections(1))

{

     <article>

     {|@if( {|Section.Heading|} != "")    

           {|if|}

                <h2>{|Section.Heading|}</h2>

           {|/if|}

           {|else|}

                <h2>Some default heading</h2>

           {|/else|}

     |}

                {|Section.SectionContent|}

           </div>

     </article>

}|}