Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

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

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

sitemap under 2.4


Go to End


4 Posts   1310 Views

Avatar
BigChris

Community Member, 63 Posts

7 July 2010 at 5:04am

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;
}

Avatar
Willr

Forum Moderator, 5523 Posts

7 July 2010 at 4:41pm

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.

Avatar
BigChris

Community Member, 63 Posts

17 July 2010 at 11:44am

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

Avatar
Willr

Forum Moderator, 5523 Posts

17 July 2010 at 1:08pm