Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to iterate on children and show fields?
#1
I am setting up an extremely simple portfolio view. What I want to do is something like this:

Code:
// Main portfolio page -- simple example without html formatting

foreach ($page->children as $child) {
    echo $child->title;
    echo $child->article_image; //i18n custom field name
}

How can I get the child pages in that sort of way? That's how I normally do it in a different CMS, so I hope I can do this with GetSimple. Thanks!
Reply
#2
very similar...

Code:
foreach (getChildren($page) as $child){
echo getPageField($child,'title');
echo getPageField($child,article_image);
}
My Github Repos: Github
Website: DigiMute
Reply
#3
Very nice. Thanks for the quick reply.
Reply
#4
or you could also use getChildrenMulti which should be a bit faster.

Code:
$children=getChildrenMulti($page,array('title','article_image'));
foreach ($children as $child){
echo $child['title'];
echo $child['article_image];
}
My Github Repos: Github
Website: DigiMute
Reply
#5
Great, this is going on a budget host so the speed tips are appreciated. Thank you.

I did have a question though--if I do something like this for an articles section, is there a modular way to add pagination (list pagination)? Or should I use some sort of blog plugin?
Reply
#6
You should check Mvlcek's plugin, as his "special pages" plug will make it easier to maintain articles of same type.
There are also a blog plugins.
Addons: blue business theme, Online Visitors, Notepad
Reply




Users browsing this thread: 2 Guest(s)