pieceofcake2/sitemap

A CakePHP 2 Plugin for adding automatic XML and HTML Sitemaps to an app

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 15

Type:cakephp-plugin

pkg:composer/pieceofcake2/sitemap

v1.0.3 2025-10-07 22:45 UTC

This package is auto-updated.

Last update: 2025-10-07 22:46:24 UTC


README

GitHub License Packagist Version PHP CakePHP CI Codecov

This is forked for CakePHP2.

A CakePHP 2.x Plugin for adding automatic XML and HTML Sitemaps to an CakePHP app

Background

  • Only generates a sitemap currently for models in the core App, not in Plugins.
  • Generates an HTML list using a dl list.
  • Generates an sitemap.xml file as well.
  • View caching used for the HTML files.
  • Allows for setting a custom callback function to build urls.

Requirements

  • PHP 8.0+
  • CakePHP 2.10+

Installation

Composer

$ composer require pieceofcake2/sitemap

Usage

  • Add this this line to your bootstrap.php:
CakePlugin::load(['Sitemap' => ['routes' => true]]);
  • Add the behavior to the model desired to generate a sitemap for that model
public $actsAs = [
    'Sitemap.Sitemap' => [
        'primaryKey' => 'id', // Default primary key field
        'loc' => 'buildUrl', // Default function called that builds a url, passes parameters (Model $Model, $primaryKey)
        'lastmod' => 'modified', // Default last modified field, can be set to FALSE if no field for this
        'changefreq' => 'daily', // Default change frequency applied to all model items of this type, can be set to FALSE to pass no value
        'priority' => '0.9', // Default priority applied to all model items of this type, can be set to FALSE to pass no value
        'conditions' => [], // Conditions to limit or control the returned results for the sitemap
    ]
];
  • Sitemap should now be visible at /sitemap and /sitemap.xml

Contributing

Reporting Issues

Please use GitHub Isuses for listing any known defects or issues.

License

MIT

Copyright

Loadsys Web Strategies 2016