Given I have Sulu CMS 2.5+ project.
I have some pages created via admin. I can see the links to pages in /sitemap.xml.
Also, I have some custom pages which are not handled via SULU core. Let’s say I have a custom route with dynamic slug.
I want to add my custom urls which depends on custom table in database to existing /sitemap.xml file. How can I add more urls to sitemap?
- I was looking for a way to expand the existing
SuluBundlePageBundleSitemapPagesSitemapProvider
provider.
I tried this service configuration to replace current provider PagesSitemapProvider
with a custom one CustomSitemapProvider
:
SuluBundlePageBundleSitemapPagesSitemapProvider:
class: AppSitemapCustomSitemapProvider
arguments:
$environment: '%kernel.environment%'
tags:
- { name: sulu.sitemap.provider, alias: custom }
with no luck. PagesSitemapProvider tried to autowire arguments with no success:
Cannot autowire service “AppSitemapCustomSitemapProvider”: argument “$environment” of method “__construct()” is type-hinted “string”, you should configure its value explicitly.
- I see a way to add links to sitemap using new SiteMapProvider by implementing
SitemapProviderInterface
.
In case of adding new sitemapProvider, I will have links to 2 sitemap files in /sitemap.xml (pages-1.xml and custom-1.xml). As far as I can understand, the number of files equals the number of providers.
It’s fine to have 2+ but my installation handles several domains (multiportal), that’s why I do not want any domain to have 2 sitemap files.
- I have better have 2 sitemap files only for a single portal.
- I have better have 1 sitemap file with some additional links just for a single portal.
I wonder if it’s possible to expand/override
“SuluBundlePageBundleSitemapPagesSitemapProvider”