PHP code example of roelofjan-elsinga / aloia-cms-publish

1. Go to this page and download the library: Download roelofjan-elsinga/aloia-cms-publish 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/ */

    

roelofjan-elsinga / aloia-cms-publish example snippets


namespace App\Console\Commands;

use SitemapGenerator\SitemapGenerator;

class SitemapCreator extends \AloiaCms\Publish\Console\SitemapCreator
{

    /**
     * Overwrite the base implementation and add additional URL's
     *
     * @param SitemapGenerator $generator
     */
    protected function appendAdditionalUrls(SitemapGenerator $generator): void
    {
        foreach($this->getArrayOfOtherUrlsToAdd() as $url) {
            $generator->add($url, 0.8, $this->lastmod, 'monthly');
        }
    }

    /**
     * Get the urls of the portfolio items
     *
     * @return array
     */
    private function getArrayOfOtherUrlsToAdd(): array
    {
        return [
            '/contact',
            '/services',
            '/any-other-urls-you-wish'
        ];
    }

}

public function register()
{
    $this->app->bind(\AloiaCms\Publish\Console\SitemapCreator::class, function () {
        return new \App\Console\Commands\SitemapCreator();
    });
}
bash
php artisan vendor:publish --provider="AloiaCms\\Publish\\ServiceProvider"