Download the PHP package charcoal/contrib-sitemap without Composer
On this page you can find all versions of the php package charcoal/contrib-sitemap. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download charcoal/contrib-sitemap
More information about charcoal/contrib-sitemap
Files in charcoal/contrib-sitemap
Package contrib-sitemap
Short Description Charcoal service for generating a sitemap.
License MIT
Homepage https://charcoalphp.github.io/contrib-sitemap/
Informations about the package contrib-sitemap
Charcoal Sitemap
A Charcoal package for generating a sitemap.
Installation
Setup
For Charcoal projects, the package can be registered in two ways.
Charcoal Module
The Sitemap's module will register the service provider (see below) and
the route (/sitemap.xml
).
The module can be registered from your configuration file:
Charcoal Service Provider
The Sitemap's service provider will register the necessary services (see below) for building a sitemap.
The service provider can be registered from your configuration file:
To register a route from your configuration file:
By default, the action controller will look for a sitemap hierarchy named xml
which can be changed via the sitemap_ident
controller setting.
Overview
Routes
GET /sitemap.xml
— A route assigned toCharcoal\Sitemap\Action\SitemapAction
.
Used to serve the XML document.
Services
charcoal/sitemap/builder
— Instance ofCharcoal\Sitemap\Service\Builder
.
Used to generate the collections of links from the configured models.sitemap/formatter/xml
— Instance ofCharcoal\Sitemap\Service\XmlFormatter
.
Used to generate the XML from one or more collections of links from theBuilder
.sitemap/presenter
— Instance ofCharcoal\Sitemap\Service\SitemapPresenter
.
Used to resolve model transformations.sitemap/transformer/factory
— Instance ofCharcoal\Factory\GenericFactory
(charcoal/factory).
Used to resolve object transformers from object types.
Configuration
The Sitemap can be configured from the application configset under the
sitemap
key. You can setup which objects to be included and available
translations (l10n).
Most options are renderable by objects using your application's chosen template syntax (Mustache used in examples below).
Default Options
json
- "
": { - "property": "active",
- "value": true
- }
- json
- "
": { - "property": "position",
- "direction": "ASC"
- }
Each model can override the following options of their group:
l10n
, locale
, check_active_routes
, relative_urls
.
Example
The example below, identified as footer_sitemap
, is marked as multilingual
using the l10n
option which will include all translations.
Usage
Using the builder
The builder returns only an array. You need to make your own converter if you need another format.
Given the settings above:
You can also use the SitemapBuilderAwareTrait
, which includes the setter and
getter for the sitemap builder, in order to use it with minimal code in every
necessary class.
XML Formatter
The XML formatter generates a valid XML sitemap from the array returned by the builder.
Development
To install the development environment:
To run the scripts (PHP lint, PHPCS, PHPStan, and PHPUnit):
License
Charcoal is licensed under the MIT license. See LICENSE for details.
All versions of contrib-sitemap with dependencies
charcoal/app Version ^4.0
charcoal/core Version ^4.0
charcoal/factory Version ^4.0
charcoal/object Version ^4.0
charcoal/translator Version ^4.0
charcoal/view Version ^4.0