GetSimple Support Forum

Full Version: Displaying child pages on the same page as parent
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi. I'm considering using GetSimple for a site. Let's imagine I have a navigation structure like so:

- Home page
-- Sub page 1
-- Sub page 2
-- Sub page 3
- Another page
-- Another sub page 1
-- Another sub page 2
-- Another sub page 3

What I want to do, is use GetSimple to generate links for pages Home page and Another page, and then display those pages together with their children. For example, when the user goes to the home page, they would see the content of the home page, but also divs with the content of sub page 1, sub page 2 and sub page 3 below it, like so:

[Image: 18-05-05.png]

Would this be at all possible with GetSimple? I'd imagine it would have to be a bit like the WordPress loop, where on every parent the children are looped and displayed in a div, but I've never used GetSimple before, so I don't really know what is possible.
Here. You want to check out getChildrenMulti() where "options" are actually the fields with data that you want to have returned. This function also works with custom fields added by other plugins like the "I18N Custom Fields" plugin.
That looks like it could work perfectly Smile From my understanding of WordPress (the two seem similar), I understand I'd be using that on the template page?
Can be done using the I18N plugin. I think that the Child Menu plugin would work too (but it doesn't support all types of permalink structures AFAIK)

You could also use something like this in your template:

PHP Code:
<?php foreach (getChildren(return_page_slug()) as $child): ?>
 <a href="<?php echo find_url($childreturn_page_slug()); ?>"><?php getPageField($child'title'); ?></a>
 <br />
<?php endforeach; ?>
not menu, content.

working code for this is actually posted somewhere in the forum I believe.

so something like this?
PHP Code:
<?php foreach (getChildren(return_page_slug()) as $child): ?>
  <div class="subpage">
   <?php getPageContent($child); ?>
<?php endforeach; ?>
yes or something like
not sure if this returns a assoc array or not
PHP Code:
$page get_page_slug(false);
getChildrenMulti($page,array('content'))) as $key=>$value){

although i would use a plugin like custom fields or something since files have to be loaded for each content as page cache is not used.
idea for plugin that adds content to pages.xml for small sites that use pages like this.
Ill probably just add this to core though as an option to cacheall

carlos, does that template syntax work in php 5.2 ?
I think that syntax is available since PHP 4.
Hi GetSimplers, meanwhile someone made a great work about "getChildrenMulti" function!!!

I tried one these PHP script and it works fine! Useful.
Hi D.O.

Thanks for posting this code.

I translated it from russian to english:


Working with sets of pages with different reciprocal relationships is fundamental when designing a website
that contains a significant amount of content.

The following snippet of PHP code can be used to display a list of child pages of the current page
in GetSimple CMS 3.4. For example, to build a list of subpages of a section.

<?php $page = get_page_slug ( false ); $children = getChildren ( $page ); echo '<ul>' ; foreach ( $children as $child ) { $url = generate_url ( $child ); echo '<li><a href="' . $url . '">' . returnPageField ( $child , 'title' ) . '</a></li>' ; } echo '</ul>' ; ?>

For code compatibility with GetSimple CMS 3.3, replace the call to the generate_url() function with find_url() :

$url = find_url ( $child , $page );

<?php $page = get_page_slug ( false ); $children = getChildren ( $page ); echo '<ul>' ; foreach ( $children as $child ) { $url = find_url ( $child ); echo '<li><a href="' . $url . '">' . returnPageField ( $child , 'title' ) . '</a></li>' ; } echo '</ul>' ; ?>

To use the code, you must place its call in the component or file of the page design template.
Welldone, Felix!
I'm wondering if this russian author is an user who we know here.

[quote='Hi D.O.

Thanks for posting this code.

I translated it from russian to english' pid='68119' dateline='1585923747']