Page 1 of 1

(SOLVED) Problem with $cgsimple->get_children

Posted: Thu Feb 18, 2010 7:25 pm
by alzambo
Hello to everybody.

I have this page structure:

Parent Page
- child1 content_block
- child2 content_block
- childn content_block

The user can add/delete/edit the children pages.
My intention is to include content_block of all n-child pages into one partent page, as a sort of query.

I then tried to search for the help of $cgsimple->get_children.
First, trying with the example loop on documentation page of CGSimpleSmarty:

{$cgsimple->get_children('','',$children)}
{if count($children)}
  {foreach from=$children item='child'}
     {if $child.show_in_menu}
       Child:  id = {$child.id} alias = {$child.alias};
     {/if}
  {/foreach}
{/if}

But with no output.... then I tried a simplified form that is:
{$cgsimple->get_children('','',$child)}
{$child.id}

And even this outputs none; I used that CGSimple code on the template of parent page.
I'm sure that 'Parent' page is recognized to have children with {$cgsimple->has_children()} returning 1.
But I cannot explain this behaviour..
Where is my mistake?

Thank you in advance!
Alex (italy)

Re: Problem with $cgsimple->get_children

Posted: Fri Feb 19, 2010 4:11 am
by fredp
Hi,

It appears example is incorrect in the module help section.  I just created a bug for this 4619

The good news is that the argument descriptions appear correct.  So, if you follow what they say, you should be able to get this to work:
   get_children([$alias],[$showinactive],[$assign])

   Return an array containing information about a pages children (if any)

   Arguments:

       * [$alias] - (optional) The page alias to test. If no value is specified, the current page is used.
       * [$showinactive] - (optional) Wether inactive pages should be included in the result (defaults to false).
       * [$assign] - (optional) The name of a variable to assign the results to.


Perhaps this modified version of the example get_children() call will work better for you (changes are underlined)...

   {$cgsimple->get_children('',false,'children')}

Hope this helps,
Fred P.

Re: Problem with $cgsimple->get_children

Posted: Fri Feb 19, 2010 12:48 pm
by alzambo
fredp wrote:    {$cgsimple->get_children('',false,'children')}
No,  :'(
it doesn't work.
I suspect that this bug to do with mle support...could it be true?

Re: Problem with $cgsimple->get_children

Posted: Fri Feb 19, 2010 10:28 pm
by fredp
alzambo wrote:
fredp wrote:    {$cgsimple->get_children('',false,'children')}
No,  :'(
it doesn't work.
I suspect that this bug to do with mle support...could it be true?
I don't know.  I haven't used MLE.  The modified example, however, does work for me with CGSimpleSmarty 1.4.3 on a CMSMS 1.6.6 installation:

Code: Select all

This is a test of get_children<br />
{$cgsimple->get_children('',false,'children')}
{if count($children)}
   {foreach from=$children item='child'}
      {if $child.show_in_menu}
        Child:  id = {$child.id} alias = {$child.alias}<br/>
      {/if}
   {/foreach}
{/if}
Sample output:

Code: Select all

This is a test of get_children
Child: id = 25190 alias = child-1
Child: id = 25191 alias = child-2
Fred P.

Re: Problem with $cgsimple->get_children

Posted: Sat Feb 20, 2010 11:30 am
by alzambo
I tried your routine on a fresh installation, without any content except for one partent page two children, but still doesn't work.

I've solved anyway using content_dump.
Thank you!
Alex

Re: (SOLVED) Problem with $cgsimple->get_children

Posted: Sat Feb 20, 2010 2:57 pm
by calguy1000
I suspect that this bug to do with mle support...could it be true?
It could be true, I don't test with the MLE version because it is an 'unsupported fork'.