Notice: You are browsing the documentation for PrestaShop 9, which is currently in development.

You might want to read the documentation for the current version, PrestaShop 8. Read the current version of this page

Hook actionModifyFrontendSitemap

Informations

Allows modules to add own urls (even whole new groups) to frontend sitemap. For example landing pages, blog posts and others.
Hook actionModifyFrontendSitemap
Locations
FO
Type action
Origin core
Aliases
Description For example landing pages, blog posts and others.

Located in

Origin File
core controllers/front/SitemapController.php

Call of the Hook in the origin file

Hook::exec(
    'actionModifyFrontendSitemap',
    ['urls' => &$sitemapUrls],
    null,
    false,
    true,
    false,
    null,
    true
);

Example implementation

public function hookActionModifyFrontendSitemap($params)
{
    $customUrls = [
        [
            'id' => 'custom-url-1',
            'label' => 'Custom URL',
            'url' => 'https://prestashop-project.org',
        ]
    ];

    $params['urls']['pages']['links'] = array_merge($params['urls']['pages']['links'], $customUrls); // add custom urls to pages group
    unset($params['urls']['categories']); // hide categories
}