Custom sitemap extension
This is an article for advanced users of Frontastic.
We use a commandline script for generating the sitemap contents of a project. We provide you with some standard sitemap features for generation in that script, for example, generating sitemap for all nodes, products, categories, and so on. In some cases, it doesn't provide you enough flexibility so you can write your own extension.
To do this, you'll need to define your extension (like all our other extensions) following the interface here:
The name is important to determine what you'll generate by that extension and will be used inside the filename of the sitemap XML file (in your
getEntries() will return the needed URLs that should be added to your sitemap. It may also contain an array of image-URLs that should be added to the sitemap URL-reference as well.
The generation of the sitemap then takes place in our sitemap generation command. You'll need to register it in order to let the command know that there is an extension that should be executed.
Registering your extension
To register your extension so that it can be executed, you need to add a tag to the corresponding service inside the
<!-- [...] --> <service id="..." class="..."> <argument type="..."> <!-- [...] --> <tag name="frontend.sitemapExtension"/> </service> <!-- [...] -->
You also need to run the script with the
--with-extensionsparameter. Otherwise, extensions won't be executed!
To use the new database sitemap feature (see the changes to sitemaps changelog for more information) you need to have the below variable in your
Updated over 1 year ago