DOCUMENTATION: add documentation for controller with sitemap
This commit is contained in:
@@ -22,13 +22,22 @@ class Sitemap extends Controller
|
|||||||
$this->content = $content;
|
$this->content = $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get sitemap for all content pages
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
public function getMap()
|
public function getMap()
|
||||||
{
|
{
|
||||||
|
// load all public pages
|
||||||
$pages = $this->content->getPageQuery()
|
$pages = $this->content->getPageQuery()
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
|
|
||||||
|
// iterate over all pages and add tag for each of them
|
||||||
foreach ($pages as $page) {
|
foreach ($pages as $page) {
|
||||||
|
|
||||||
|
// is this page a homepage? because of URL
|
||||||
if ($page->is_homepage) {
|
if ($page->is_homepage) {
|
||||||
$route = route('page.index');
|
$route = route('page.index');
|
||||||
$priority = 1;
|
$priority = 1;
|
||||||
@@ -37,10 +46,12 @@ class Sitemap extends Controller
|
|||||||
$priority = 0.8;
|
$priority = 0.8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// add to all pages
|
||||||
\Sitemap::addTag($route, $page->updated_at, 'daily', $priority);
|
\Sitemap::addTag($route, $page->updated_at, 'daily', $priority);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// print sitemap
|
||||||
return \Sitemap::render();
|
return \Sitemap::render();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user