Jump to:

3439 Posts in 1028 Topics by 869 members

Template Questions

SilverStripe Forums » Template Questions » SiteMap $rootLevel

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

Page: 1
Go to End
Author Topic: 1885 Views
  • Jurgen Jessurun
    Avatar
    Community Member
    9 Posts

    SiteMap $rootLevel Link to this post

    How can I present different types in my sitemap.

    Standard it only present the rootlevel type Page. What if, for example, there is a articlePage and a Page type?

    function SiteMap() {
    $rootLevel = DataObject::get("Page", "ParentID = 0"); // Pages at the root level only
    $output = "";
    $output = $this->makeList($rootLevel);
    return $output;
    }

  • Nivanka
    Avatar
    Community Member
    395 Posts

    Re: SiteMap $rootLevel Link to this post

    this is easy,

    just add the articlePage type to that too

    function SiteMap() {
    $rootLevel = DataObject::get("Page", "ParentID = 0"); // Pages at the root level only
    $output = "";
    $output = $this->makeList($rootLevel);
    $articlePages = DataObject::get("ArticlePage", "ParentID = 0"); // Pages at the root level only
    $output = $this->makeList($articlePages);
    return $output;
    }

  • Nivanka
    Avatar
    Community Member
    395 Posts

    Re: SiteMap $rootLevel Link to this post

    I forgot to mention, on the first Page.php the make list function can be further edited to make the page levels too, with adding sub lists, and so on.

  • Jurgen Jessurun
    Avatar
    Community Member
    9 Posts

    Re: SiteMap $rootLevel Link to this post

    It doesn't seem to work, can you please explain further?

  • Jurgen Jessurun
    Avatar
    Community Member
    9 Posts

    Re: SiteMap $rootLevel Link to this post

    Problem solved. Sitemap works fine.   

    function SiteMap()
    {
    $output = "";

    $rootLevel = DataObject::get("SiteTree", "ParentID = 0");
    $output = $this->makeList($rootLevel);

    return $output;
    }

  • mwalsh
    Avatar
    Community Member
    21 Posts

    Re: SiteMap $rootLevel Link to this post

    Thanks for posting this, that's has solved my problem too.

    1885 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.