Iteration child pages > reading ECB vars

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Locked
User avatar
AccentAvondschool
Forum Members
Forum Members
Posts: 43
Joined: Sun May 08, 2016 5:36 am

Iteration child pages > reading ECB vars

Post 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
User avatar
AccentAvondschool
Forum Members
Forum Members
Posts: 43
Joined: Sun May 08, 2016 5:36 am

Iteration child pages > reading ECB vars

Post 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
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1978
Joined: Mon Jan 29, 2007 4:47 pm

Re: Iteration child pages > reading ECB vars

Post 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.
"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!
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: Iteration child pages > reading ECB vars

Post 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.
Jeff
Power Poster
Power Poster
Posts: 961
Joined: Mon Jan 21, 2008 5:51 pm

Re: Iteration child pages > reading ECB vars

Post by Jeff »

It maybe be easier and more effecent to use a List type module like LISE.
User avatar
AccentAvondschool
Forum Members
Forum Members
Posts: 43
Joined: Sun May 08, 2016 5:36 am

Re: Iteration child pages > reading ECB vars

Post 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.
Locked

Return to “Modules/Add-Ons”