PHP code example of kokspflanze / zfc-sitemap

1. Go to this page and download the library: Download kokspflanze/zfc-sitemap library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

kokspflanze / zfc-sitemap example snippets




namespace App\Core\Listener;

use Laminas\EventManager;
use Laminas\Navigation\AbstractContainer;
use ZfcSitemap\Service\Sitemap;

class SitemapCustom extends EventManager\AbstractListenerAggregate
{
    /**
     * @inheritDoc
     */
    public function attach(EventManager\EventManagerInterface $events, $priority = 1)
    {
        $this->listeners[] = $events->attach(Sitemap::EVENT_SITEMAP, [$this, 'onSiteMap'], $priority);
    }

    /**
     * @param EventManager\EventInterface $event
     */
    public function onSiteMap(EventManager\EventInterface $event)
    {
        /** @var AbstractContainer $container */
        $container = $event->getParam('container');

        $container->addPage([
            'label' => 'Example',
            'uri' => '/example',
        ]);
        /**
        *  your custom stuff, add or remove pages
         */

        $event->setParam('container', $container);
    }

}

    'zfc-sitemap' => [
        'strategies' => [
            Listener\SitemapCustom::class,
        ],
    ],
sh
php composer.phar  version, type `dev-master`)