1 <?php
2
3 class SiteMap_Controller extends Page_Controller {
4 static $has_many = array();
5
6 function init() {
7 parent::init();
8 $this->data()->URLSegment = 'sitemap.html';
9 }
10
11 function SiteMap($level = 3) {
12 return $this->makeList2($level, 1, DataObject::get("Page", "ParentID = 0"));
13 }
14
15 private function makeList2($maxLevel, $level, $pages) {
16 $output = new DataObjectSet();
17
18 if($level <= $maxLevel && count($pages)) {
19 foreach($pages as $page) {
20 if (!($page instanceof ErrorPage) && $page->ShowInSiteMap && ($page->Title != $this->Title()) && $page->canView()){
21 $page->MapChildren = $this->makeList2($maxLevel, $level+1, DataObject::get("Page", "ParentID = ".$page->ID));
22 $output->push($page);
23 }
24 }
25 }
26 return $output;
27 }
28
29 function Title() {
30 return _t('Webylon.SITEMAP','Карта сайта');
31 }
32
33 }
34
35
[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the
Silverstripe Forums to ask development related questions.
-