Using the API
The main functionality of this extension is to provide a PHP API which allows to locate XML sitemaps for a given site and optional site language. Read more about how to use this API on this page.
- class SitemapLocator
-
- Fully qualified name
-
\Elias
Haeussler\ Typo3Sitemap Locator\ Sitemap\ Sitemap Locator
Service to locate XML sitemaps of a given site.
- locateBySite ( $site, $siteLanguage = null)
-
Locate XML sitemaps of the given site and site language.
- param TYPO3\CMS\Core\Site\Entity\Site $site
-
The site whose XML sitemap path should be located.
- param TYPO3\CMS\Core\Site\Entity\SiteLanguage $siteLanguage
-
An optional site language to include while locating the XML sitemap path.
- Returns
-
An array of instances of
\Elias
.Haeussler\ Typo3Sitemap Locator\ Domain\ Model\ Sitemap
- locateAllBySite ( $site)
-
Locate XML sitemaps of the given site and all their available languages.
- param TYPO3\CMS\Core\Site\Entity\Site $site
-
The site whose XML sitemap path should be located.
- Returns
-
An array of instances of
\Elias
, indexed by the site language id.Haeussler\ Typo3Sitemap Locator\ Domain\ Model\ Sitemap
Example
use EliasHaeussler\Typo3SitemapLocator;
use TYPO3\CMS\Core;
$sitemapLocator = Core\Utility\GeneralUtility::makeInstance(Typo3SitemapLocator\Sitemap\SitemapLocator::class);
$siteFinder = Core\Utility\GeneralUtility::makeInstance(Core\Site\SiteFinder::class);
$sitemaps = [];
// Fetch all available sites
$sites = $siteFinder->getAllSites();
// Locate XML sitemaps of each site
foreach ($sites as $site) {
$sitemaps[$site->getIdentifier()] = $sitemapLocator->locateBySite($site);
}