(SOLVED) Problem with $cgsimple->get_children

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Locked
alzambo
Forum Members
Forum Members
Posts: 26
Joined: Tue Jun 23, 2009 7:02 pm

(SOLVED) Problem with $cgsimple->get_children

Post 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)
Last edited by alzambo on Sat Feb 20, 2010 11:31 am, edited 1 time in total.
fredp
Forum Members
Forum Members
Posts: 218
Joined: Sun Jul 27, 2008 1:36 am

Re: Problem with $cgsimple->get_children

Post 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.
Last edited by fredp on Fri Feb 19, 2010 4:22 am, edited 1 time in total.
Nearly all men can stand adversity, but if you want to test a man's character, give him power.
- Abraham Lincoln
alzambo
Forum Members
Forum Members
Posts: 26
Joined: Tue Jun 23, 2009 7:02 pm

Re: Problem with $cgsimple->get_children

Post 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?
fredp
Forum Members
Forum Members
Posts: 218
Joined: Sun Jul 27, 2008 1:36 am

Re: Problem with $cgsimple->get_children

Post 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.
Nearly all men can stand adversity, but if you want to test a man's character, give him power.
- Abraham Lincoln
alzambo
Forum Members
Forum Members
Posts: 26
Joined: Tue Jun 23, 2009 7:02 pm

Re: Problem with $cgsimple->get_children

Post 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
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

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

Post 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'.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Locked

Return to “Modules/Add-Ons”