Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
#CMSMS snippet: Single page website, content from subpages having multiple blocks
- Display multiple content blocks on a single page, using CGSimpleSmarty and DesignManager Core::Generic
- install the CGSimpleSmarty module
- add a root page with alias 'main'
- add a few child pages for example ['child_one' || 'child_two'] having a content block
- add some generic templates via: Design Manager -> Templates -> add Core::Generic
- name the generic templates the same as the alias of the child page,
for example: ['cg__child_one' || 'cg__child_two']
- from within cg__child_one call: "snippet_1"
- from within cg__child_two call: "snippet_2"
- from within the root page call: "snippet_root"
{* snippet_1: you can assign multiple content blocks ! *}
{$content_en_child_one="{cgsimple::get_page_content('child_one','')}" scope=global}
{* snippet_2: you can assign multiple content blocks *}
{$content_en_child_two="{cgsimple::get_page_content('child_two','')}" scope=global}
{* snippet_root *}
{$children=cgsimple::get_children('main', '', 'children')}
{if count($children)}
{foreach from=$children item='child'}
{if $child.show_in_menu}
{capture assign='_file'}cms_template:cg__{$child.alias}{/capture}
{include file=$_file assign='_txt'}
{eval var=$_txt}

This comment has been minimized.

Copy link

commented Sep 21, 2016

it should be much more simple.. this should work (untested). No need for generic templates... or a naming convention.

{$children=cgsimple::get_children()} {* cgsimple::get_children will get the children of the current page if no alias specified *} 
{if count($children)}
   {foreach $children as $child}
      {if $child.show_in_menu}
         {$_txt=cgsimple::get_page_content($child.alias)}{* uses the default content block if no block specified *}
         {eval var=$_txt}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.