Jump to:

23453 Posts in 18902 Topics by 2877 members

General Questions

SilverStripe Forums » General Questions » Accessing an individual children?

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 867 Views
  • tomklang
    Avatar
    Community Member
    6 Posts

    Accessing an individual children? Link to this post

    Hi!

    Can somebody explain a simple way how to access an individual children (Article Title/Body) without using
    the control childrenOf command?

    The disadvantage here is that you have to define an additional layer within the site structure...

    Thanks for your help

  • Willr
    Avatar
    Forum Moderator
    5497 Posts

    Re: Accessing an individual children? Link to this post

    Sorry perhaps not really understanding the question. If you want a specific page on the site you can use <% control Page(page-url) %> to get a single page regardless of what the site structure is.

  • tomklang
    Avatar
    Community Member
    6 Posts

    Re: Accessing an individual children? Link to this post

    Thanks,

    is it also possible to access the children by a parameter "order",
    meaning the first, second, third etc.... in order of appearance within the cms interface?

    best,
    tom

  • carlos
    Avatar
    Community Member
    41 Posts

    Re: Accessing an individual children? Link to this post

    Hi,

    you can create a function to do that.

    $children = DataObject::get("SiteTree","ParentID = '$this->ID'","Date DESC");
    if($children) return $children;
    return null;

    867 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.