1. Go to this page and download the library: Download adnan0703/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/ */
adnan0703 / sitemap example snippets
php
// in Posts table class
public function sitemapQuery()
{
return $this->find()
->select(['id', 'name'])
->where(['published' => true]);
}
php
// in Posts entity class
protected function _getSitemapEntry()
{
return [
'url' => $url, //
php
set_time_limit(60*10); // if you have lots of records
$models = ['Posts'];
$dirPath = WWW_ROOT . DS . 'sitemaps';
$sitemap = new \Adnan0703\Sitemap\Lib\Sitemap();
$mainSitemap = $sitemap->createSitemap(
$dirPath,
'http://example.com/sitemaps/',
$models,
true
);
// $mainSitemap will be 'http://example.com/sitemaps/sitemap.xml'
php
Configure::write('Sitemap.findLimit', 600);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.