Jump to:

22984 Posts in 11765 Topics by 2827 members

General Questions

SilverStripe Forums » General Questions » sitemap under 2.4

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: 858 Views
  • BigChris
    Avatar
    Community Member
    63 Posts

    sitemap under 2.4 Link to this post

    Hello,

    I am using a modified version of the sitemap tutorial and have a question about the new URLsegment under version 2.4.

    Function has been modified from the sitemap tutorial. But the $page->URLSegment is outputting the correct page name but as it is in some instances a sub page of a page, the parent page can be missing.

    Any ideas?

    Cheers
    Chris

    code below.

    private function makeList($pages) {
    $output = "";
    if(count($pages)) {
    $output = '
    <ul id="sitemap-list">';
    foreach($pages as $page) {
    if(!($page instanceof ErrorPage) && $page->ShowInMenus && $page->Title != $this->Title){
    $output .= '
    <li><a href="'.$page->URLSegment.'" title="'.Convert::raw2xml($page->Title).' page">'.Convert::raw2xml($page->MenuTitle).'</a>';
    $whereStatement = "ParentID = ".$page->ID;
    //$childPages = new DataObjectSet();
    $childPages = DataObject::get("Page", $whereStatement);
    $output .= $this->makeList($childPages);
    $output .= '
    </li>';
    }
    }
    $output .= '
    </ul>';
    }
    return $output;
    }

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: sitemap under 2.4 Link to this post

    Instead of using URLSegment there is now a method Link() which generates funnily enough the link to the page so use $page->Link() is what you want.

  • BigChris
    Avatar
    Community Member
    63 Posts

    Re: sitemap under 2.4 Link to this post

    Will,

    Thank you for your reply. That solved it perfectly. Can I ask where can I find out about the new functionality is it in the api or docs?

    Cheers
    Chris

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: sitemap under 2.4 Link to this post

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