This snippet generates sitemaps such as Google XML sitemap, HTML sitemap and/or any custom format.
- MODx Revolution 2.1.5 or later
- PHP5 or later
sitemapFriend was written by Mihai Sucan and is based on the GoogleSiteMap snippet by Shaun McCormick. It was released on November 16, 2010.
Mihai retired from developping under Modx and the plugin is currently maintained by Jérôme Perrin.
Feature requests and bugs can be filed on github.
To generate a sitemap in some custom format, create your own chunks and tell the snippet to use them. Check the list of available templates below.
Hint: use the getCache snippet for custom caching control of your sitemaps.
The snippet is made such that you can generate almost any kind of sitemap. Control the output using the following lists of properties.
Properties can be set in the snippet call or in property sets.
|type||The type of sitemap to generate: xml or html. Depending on this property, other properties will change their default value.||html|
|titleField||The title: pagetitle, longtitle, menutitle. Falls back to pagetitle to prevent empty titles.||pagetitle|
|urlScheme|| The URL scheme for non-XML sitemaps: http, https, full, abs, etc. See the $modx->makeUrl() documentation.
For XML sitemaps, it's always set to full.
|startId||Build the sitemap starting from the given resource ID.||0|
|contexts||Limit to the specified context(s). If empty, will grab resources from current Context. Can support a comma-separated list.|
|showDeleted||Include deleted resources?||false|
|showUpublished||Include unpublished resources?||false|
|onlySearchable||Only include searchable resources?||true|
|showHidden||Include resources which are not visible in the menus?||true|
|maxDepth||The maximum depth down the tree to grab resources from. If set to empty or 0, will grab all resources.||0|
|onlyTemplates||A comma-separated list of template IDs to filter by.|
|skipTemplates||A comma-separated list of template IDs to skip.|
|includeWebLinks||Include weblink resources?||false|
|excludeResources||A comma-separated list of resources to exclude entirely from the sitemap. Child resources will also be excluded. The resources pointed at by the Modx options error_page, site_unavailable_page, unauthorized_page and the sitemap page itself are always excluded.|
|skipResources||A comma-separated list of resources to hide from the sitemap. Child resources will NOT be excluded.|
|includeResources||A comma-separated list of resources to always include in the sitemap, even if the given resource would otherwise be filtered out by the showDeleted, showUnpublished, onlySearchable and showHidden properties.|
|excludeChildrenOf||A comma-separated list of resources for which you do not want to have their children included in the sitemap. Note that the resources you list here will be included, only the children will be skipped.|
|parentTitles||Include parent resource titles in the sitemap?||false|
|parentTitlesReversed||If parentTitles is used, should the titles be presented in a reversed order?||false|
|titleSeparator||If parentTitles is used, set the titles separator string.||-|
|sortBy||The resource field to sort the results by.||menuindex|
|sortDir||The direction to sort in.||ASC|
|lastmodFormat|| Last modification date format for non-XML sitemaps. See PHP date() function.
For XML sitemaps, the c value is always used (ISO 8601 date format).
|F j, Y, g:i a|
|tplOuter||The chunk to use, for non-XML sitemaps, as an outer container for the entire sitemap output.||sitemap_html_outer.chunk.tpl|
|tplItem|| The chunk to use, for non-XML sitemaps, for each result item.
Children items will be wrapper inside a tplContainer.
|tplContainer||The chunk to use, for non-XML sitemaps, as a wrapper for the children of a resource folder.||sitemap_html_container.chunk.tpl|
The default chunk used as an outer container for the entire sitemap output.
|startId||The sitemap start resource ID.|
|items||The entire sitemap output string.|
The default chunk used for each result item.
|parent||Holds the parent resource ID.|
|id||The ID of the resource being processed.|
|url||The URL of the resource.|
|lastmod||The last modification date for the resource.|
|title||Resource title. This can include the title of each parent resource as well, if parentTitles is set to true.|
|items||Holds the sitemap output for the child resources, if any. This allows you to nest resources in output, like in an HTML sitemap. See how this is used in the sitemap_html_item.chunk.tpl|
|changefreq||Resource change frequency, which is computed based on the last modification date. Available only for XML sitemaps.|
|priority||Resource priority, again computed based on last modification date. Available only for XML sitemaps.|
The default chunk used as a wrapper for the children of a resource folder.
|depth||Current resource depth.|
|id||Current resource ID, for which we have generated output.|
|items||The output string that lists the child resources.|
The default chunk used for XML sitemaps as an outer container for the entire sitemap output.
The default chunk used for XML sitemaps for each result item.