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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Template Questions /

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

SiteMap $rootLevel


Go to End


6 Posts   3129 Views

Avatar
Jurgen Jessurun

Community Member, 9 Posts

20 December 2008 at 12:45pm

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

Avatar
Nivanka

Community Member, 400 Posts

22 December 2008 at 3:06pm

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

Avatar
Nivanka

Community Member, 400 Posts

22 December 2008 at 3:08pm

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.

Avatar
Jurgen Jessurun

Community Member, 9 Posts

22 December 2008 at 10:09pm

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

Avatar
Jurgen Jessurun

Community Member, 9 Posts

23 December 2008 at 12:18pm

Problem solved. Sitemap works fine.

function SiteMap()
{
$output = "";

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

return $output;
}

Avatar
mwalsh

Community Member, 21 Posts

3 April 2009 at 9:09pm

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