CakePHP3 Sitemap Plugin
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config
src
tests
.gitignore
README.md
VERSION.txt
composer.json
composer.lock
phpunit.xml.dist

README.md

Sitemap plugin for CakePHP

Installation

You can install this plugin into your CakePHP application using composer.

The recommended way to install composer packages is:

composer require fm-labs/cakephp3-sitemap

Usage

Enable Sitemap plugin with default sitemap routes in your config/bootstrap.php

Plugin::load('Sitemap', ['routes' => true]);

Configuration

Create config/sitemap.php with a mapping of Sitemap providers

return [
    'Sitemap' => [
        'posts' => '\\App\\Sitemap\\MyPostsSitemapProvider'  
    ]
]

Sitemap routes

  • /sitemap.xml -> SitemapController::index()
  • /sitemap_:sitemap.xml -> SitemapController::view($sitemap)
  • /sitemap_:sitemap-:page.xml -> SitemapController::view($sitemap, $page)

Create sitemap providers

Create a class implementing the Sitemap\Lib\SitemapProviderInterface

Create sitemap providers for models

Create a class extending the Sitemap\Lib\ModelSitemapProvider

  • Set $modelClass
  • Implement abstract find() method to find model records
  • Implement abstract compile() method to create/filter sitemap locations from result set

Customized SitemapController

  • copy plugin's SitemapController to your app's controller dir
  • disable Sitemap plugin routes
  • create your own sitemap routes pointing to your sitemap controller
  • may use SitemapComponent to create sitemaps
  • may use SitemapXmlView to render sitemaps