PHP code example of axllent / silverstripe-sitemap

1. Go to this page and download the library: Download axllent/silverstripe-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/ */

    

axllent / silverstripe-sitemap example snippets


Sitemap::register_dataobject('MyDataObject');

Sitemap::register_dataobject('MyDataObject', array(
	'filter' => array('ShowOnWeb' => 1),
	'where' => '"ExpiryDate" >= \'' . date('Y-m-d') . '\' OR "ExpiryDate" IS NULL',
	'exclude' => array('StockLevel' => 0),
	'filterByCallback' => function($dataobject, $list) {return $dataobject->canView();}
	'frequency' => 'weekly', // always, hourly, daily, weekly, monthly, yearly, never
	'priority' => 0.5 // Valid values range from 0.0 to 1.0
));

Sitemap::enable_google_notifications();