Posts: 2
Threads: 1
Joined: Aug 2014
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:
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.
Posts: 52
Threads: 2
Joined: May 2013
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.
Posts: 2
Threads: 1
Joined: Aug 2014
That looks like it could work perfectly
From my understanding of WordPress (the two seem similar), I understand I'd be using that on the template page?
Posts: 3,491
Threads: 106
Joined: Mar 2010
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($child, return_page_slug()); ?>"><?php getPageField($child, 'title'); ?></a>
<br />
<?php endforeach; ?>
Posts: 6,267
Threads: 182
Joined: Sep 2011
not menu, content.
working code for this is actually posted somewhere in the forum I believe.
Posts: 3,491
Threads: 106
Joined: Mar 2010
oops
so something like this?
PHP Code:
<?php foreach (getChildren(return_page_slug()) as $child): ?>
<div class="subpage">
<?php getPageContent($child); ?>
</div>
<?php endforeach; ?>
Posts: 6,267
Threads: 182
Joined: Sep 2011
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.
Posts: 6,267
Threads: 182
Joined: Sep 2011
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 ?
Posts: 3,491
Threads: 106
Joined: Mar 2010
I think that syntax is available since PHP 4.
Posts: 321
Threads: 15
Joined: Feb 2012
Hi GetSimplers, meanwhile someone made a great work about "getChildrenMulti" function!!!
http://dimayakovlev.ru/notebook/gruppirovka-i-filtraciya-vyvoda-stranic-po-godu-publikacii-v-getsimple-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
Posts: 515
Threads: 21
Joined: Feb 2019
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.
Posts: 321
Threads: 15
Joined: Feb 2012
2020-04-10, 01:23:04
(This post was last modified: 2020-04-10, 01:24:56 by D.O..)
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