Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QUESTION Displaying child pages on the same page as parent
#1
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.
Reply
#2
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.
Reply
#3
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?
Reply
#4
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; ?>
Reply
#5
not menu, content.

working code for this is actually posted somewhere in the forum I believe.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#6
oops

so something like this?
PHP Code:
<?php foreach (getChildren(return_page_slug()) as $child): ?>
  <div class="subpage">
   <?php getPageContent($child); ?>
  </div>
<?php endforeach; ?>
Reply
#7
yes or something like
not sure if this returns a assoc array or not
PHP Code:
$page get_page_slug(false);
foreach(
getChildrenMulti($page,array('content'))) as $key=>$value){
echo 
$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.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#8
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 ?
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#9
I think that syntax is available since PHP 4.
Reply
#10
Hi GetSimplers, meanwhile someone made a great work about "getChildrenMulti" function!!!

http://dimayakovlev.ru/notebook/gruppiro...imple-cms/

I tried one these PHP script and it works fine! Useful.
My website made with GetSimple CMS is

Arte & Società
www.artesocieta.eu

An indipendent website about Italian Contemporary Visual Arts
Reply
#11
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.
Reply
#12
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']
My website made with GetSimple CMS is

Arte & Società
www.artesocieta.eu

An indipendent website about Italian Contemporary Visual Arts
Reply




Users browsing this thread: 1 Guest(s)