Page 1 of 1

Iteration child pages > reading ECB vars

Posted: Sun May 08, 2016 6:05 am
by AccentAvondschool
Hi,

I'm running a website for a school on CMS Made Simple v1.12.1

I've put all our courses as a child from "Course Map".
On the course page I use ECB for the schooldays, something like the following ...

Code: Select all

{content_module module="ECB" field="checkbox" block='day_mo' assign="day_mo" label="Monday" tab='Accent options'}
{content_module module="ECB" field="checkbox" block='day_tu' assign="day_tu" label="Tuesday" tab='Accent options'}
{content_module module="ECB" field="checkbox" block='day_we' assign="day_we" label="Wednesday" tab='Accent options'}
...
On page "Course Map" I want to make an overview with the schooldays (checked).
I've made an GCB with the following code ...

Code: Select all

<table>
{foreach from=$cgsimple->get_children('','',$children) item='child'}
  {if $child.show_in_menu} 
    <tr><td>{$cgsimple->get_page_title($child.alias)}</td><td>{$day_mo}</td>...</tr>
  {/if}
{/foreach}
<table>
I fail to read the lesson days in the iteration. I know simply using var {$day_mo} is not working in this iteration but how to get the ECB vars in this iteration?

Someone help me with this?
Regards

Iteration child pages > reading ECB vars

Posted: Sun May 08, 2016 11:13 am
by AccentAvondschool
With my first message (Iteration child pages > reading ECB vars) I accidentally pressed on 'Solved', cannot unlock it, topic is not solved ;(

With the page iteration I try to read the content blocks per page ...

Code: Select all

{content_module module="ECB" ...}
or

Code: Select all

{content block="extra_block" ...}
But I can not solve it even with Google.

Thx
cmsms newbie

Re: Iteration child pages > reading ECB vars

Posted: Sun May 08, 2016 11:49 am
by Jo Morg
AccentAvondschool wrote:With my first message (Iteration child pages > reading ECB vars) I accidentally pressed on 'Solved', cannot unlock it, topic is not solved ;(
Unlocked and merged.

Re: Iteration child pages > reading ECB vars

Posted: Sun May 08, 2016 4:27 pm
by velden
Have a look at the help of CGSimpleSmarty module:
get_page_content($alias[,$block][,$assign])

Returns the text of a specific content block of another page.

Arguments:

$alias - The page alias to extract content from.
[$block] - (optional) The name of the content block in the specified page. If this variable is not specified the value of the default content block (content_en) is assumed.
[$assign] - (optional) The name of a variable to assign the results to.
I don't know how CMSMS internally works regarding this but it *could* be ineffecient.

You have to call it multiple times per page (like 5 or 7 times I guess, once for every weekday) and every time a content object needs to be created to get the value (not sure CMSMS does it over and over again or keeps the object in memory).

Alternatively you could have a look at this post:
http://www.cmscanbesimple.org/blog/conv ... ity-images
It would use only one field for all weekdays. But editors need to understand how to fill in.

Another alternative would be to create a UDT to get the values from the different content blocks per content object (page) and return a table row. This would however require some knowledge of PHP and CMSMS API.

Re: Iteration child pages > reading ECB vars

Posted: Sun May 08, 2016 5:58 pm
by Jeff
It maybe be easier and more effecent to use a List type module like LISE.

Re: Iteration child pages > reading ECB vars

Posted: Mon May 09, 2016 8:40 am
by AccentAvondschool
Hi all,

@Velden
Thank you. Maybe it is efficiently as you said but it works and is pretty fast. Didn't know 'get_page_content' was also for reading content blocks. I use the following in my iteration (unformatted example) ...

Code: Select all

<table>
{foreach from=$cgsimple->get_children('','',$children) item='child'}
  {if $child.show_in_menu}
    <tr><td>{$cgsimple->get_page_title($child.alias)}</td><td>{$cgsimple->get_page_content($child.alias, 'day_mo')}</td><td>{$cgsimple->get_page_content($child.alias, 'day_tu')}</td><td>...</td></tr>
  {/if}
{/foreach}
<table>
Now can I style the output (=1) to a check mark!

@Jeff
Thx, I will certainly look at that module.