Turn-key ProcessWire module for easily configuring and rendering sitemap.xml output.
Part of the ProDevTools series of modules. See documentation.
Usage example (/site/templates/sitemap-xml.php):
$sitemap = $modules->get('WireSitemapXML');
$sitemap->addPage('/some/hidden/page/');
$sitemap->setPriorityByTemplate('home', 1.0);
$sitemap->setChangefreqByTemplate('blog', 'weekly');
$sitemap->setUrlSegmentsByTemplate('blog-post', [ 'foo', 'bar', 'baz' ]);
$sitemap->execute();
return $this->halt();
Click any linked item for full usage details and examples. Hookable methods are indicated with the icon. In addition to those shown below, the Wire
class also inherits all the methods and properties of: WireData and Wire.
Common
Name | Return | Summary | |
---|---|---|---|
$sitemap->execute() $sitemap->execute() $sitemap->execute() | (nothing) | Render and output sitemap | |
$sitemap->setCacheTime() $sitemap->setCacheTime(int $cacheTime) $sitemap->setCacheTime(int $cacheTime) | self | Set how long sitemap should be cached |
Pages
Changefreq
Name | Return | Summary | |
---|---|---|---|
$sitemap->getChangefreq() $sitemap->getChangefreq(Page $page) $sitemap->getChangefreq(Page $page) | string | Get changefreq for given page | |
$sitemap->setChangefreqByPage() $sitemap->setChangefreqByPage($page, string $changefreq) $sitemap->setChangefreqByPage($page, string $changefreq) | self | Set changefreq (change frequency) by page | |
$sitemap->setChangefreqByTemplate() $sitemap->setChangefreqByTemplate($template, string $changefreq) $sitemap->setChangefreqByTemplate($template, string $changefreq) | self | Set changefreq by template | |
$sitemap->setChangefreqByTemplates() $sitemap->setChangefreqByTemplates(array $changefreqsByTemplate) $sitemap->setChangefreqByTemplates(array $changefreqsByTemplate) | self | Set changefreq by multiple templates at once |
Priority
Name | Return | Summary | |
---|---|---|---|
$sitemap->getPriority() $sitemap->getPriority(Page $page) $sitemap->getPriority(Page $page) | string | Get priority for given page | |
$sitemap->setPriorityByPage() $sitemap->setPriorityByPage($page, $priority) $sitemap->setPriorityByPage($page, $priority) | self | Set priority by page | |
$sitemap->setPriorityByTemplate() $sitemap->setPriorityByTemplate($template, $priority) $sitemap->setPriorityByTemplate($template, $priority) | self | Set priority by template | |
$sitemap->setPriorityByTemplates() $sitemap->setPriorityByTemplates(array $priorityByTemplate) $sitemap->setPriorityByTemplates(array $priorityByTemplate) | self | Set priority by multiple templates at once |
URL segments
Name | Return | Summary | |
---|---|---|---|
$sitemap->allowUrlSegment() $sitemap->allowUrlSegment(Page $page, string $urlSegmentStr) $sitemap->allowUrlSegment(Page $page, string $urlSegmentStr, $language = null) | bool | Allow URL segment string for page? (hookable) | |
$sitemap->getUrlSegments() $sitemap->getUrlSegments(Page $page) $sitemap->getUrlSegments(Page $page) | array | Get URL segments to render for given page | |
$sitemap->setUrlSegmentsByTemplate() $sitemap->setUrlSegmentsByTemplate($template, array $urlSegments) $sitemap->setUrlSegmentsByTemplate($template, array $urlSegments) | self | Set URL segments by template | |
$sitemap->setUrlSegmentsByTemplates() $sitemap->setUrlSegmentsByTemplates(array $urlSegmentsByTemplate) $sitemap->setUrlSegmentsByTemplates(array $urlSegmentsByTemplate) | self | Set URL segments by multiple templates at once |
Languages
Name | Return | Summary | |
---|---|---|---|
$sitemap->addLanguage() $sitemap->addLanguage(Language $language, string $langCode) $sitemap->addLanguage(Language $language, string $langCode) | self | Add language to include in sitemap | |
$sitemap->allowLanguage() $sitemap->allowLanguage(Page $page, Language $language) $sitemap->allowLanguage(Page $page, Language $language) | bool | Allow page to be rendered in sitemap for given $language? (hookable) | |
$sitemap->getLanguages() $sitemap->getLanguages() $sitemap->getLanguages() | array | Get languages to render in indexed by hreflang code |
For hooks
These methods are only useful for hooking and should not be called directly.
Additional methods and properties
In addition to the methods and properties above, Wire
API reference based on ProcessWire core version 3.0.236