21495 Posts in 5784 Topics by 2622 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 764 Views |
-
sitemap under 2.4

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
Chriscode 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;
} -
Re: sitemap under 2.4

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.
-
Re: sitemap under 2.4

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 -
Re: sitemap under 2.4

17 July 2010 at 1:08pm
A small note is available on the upgrading page - http://doc.silverstripe.org/upgrading:2.4.0#sitetree-_link_instead_of_sitetree-_urlsegment.
| 764 Views | ||
|
Page:
1
|
Go to Top |


