1 <?php
2
3 class SiteMap_Controller extends Page_Controller {
4 static $has_many = array();
5
6 function SiteMap($level = 3) {
7 return $this->makeList2($level, 1, DataObject::get("Page", "ParentID = 0"));
8 }
9
10 private function makeList2($maxLevel, $level, $pages) {
11 $output = new DataObjectSet();
12
13 if($level <= $maxLevel && count($pages)) {
14 foreach($pages as $page) {
15 if (!($page instanceof ErrorPage) && $page->ShowInSiteMap && ($page->Title != $this->Title()) && $page->canView()){
16 $page->MapChildren = $this->makeList2($maxLevel, $level+1, DataObject::get("Page", "ParentID = ".$page->ID));
17 $output->push($page);
18 }
19 }
20 }
21 return $output;
22 }
23
24 function Title() {
25 return _t('Webylon.SITEMAP','Карта сайта');
26 }
27 }
28
29
[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.
-