Configuration Reference

1.3 version
Maintained Unmaintained
1.2

Configuration Reference

The SeoBundle can be configured under the cmf_seo key in your application configuration. When using XML, you can use the http://cmf.symfony.com/schema/dic/seo namespace.

Configuration

persistence

phpcr

  • YAML
    1
    2
    3
    4
    5
    6
    # app/config/config.yml
    cmf_seo:
        persistence:
            phpcr:
                enabled: false
                manager_name: ~
    
  • XML
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    <!-- app/config/config.xml -->
    <?xml version="1.0" encoding="UTF-8" ?>
    <container xmlns="http://symfony.com/schema/dic/services">
        <config xmlns="http://cmf.symfony.com/schema/dic/seo">
            <persistence>
                <phpcr
                    enabled="false"
                    manager-name="null"
                />
            </persistence>
        </config>
    </container>
    
  • PHP
    1
    2
    3
    4
    5
    6
    7
    8
    $container->loadFromExtension('cmf_seo', array(
        'persistence' => array(
            'phpcr' => array(
                'enabled' => false,
                'manager_name' => null,
            ),
        ),
    ));
    
enabled

type: boolean default: false

If true, PHPCR is enabled in the service container.

If the CoreBundle is registered, this will default to the value of cmf_core.persistence.phpcr.enabled.

PHPCR can be enabled by multiple ways such as:

  • YAML
    1
    2
    3
    4
    5
    6
    phpcr: ~ # use default configuration
    # or
    phpcr: true # straight way
    # or
    phpcr:
        manager: ... # or any other option under 'phpcr'
    
  • XML
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    <persistence>
        <!-- use default configuration -->
        <phpcr />
    
        <!-- or setting it the straight way -->
        <phpcr>true</phpcr>
    
        <!-- or setting an option under 'phpcr' -->
        <phpcr manager="..." />
    </persistence>
    
  • PHP
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    $container->loadFromExtension(..., array( // bundle configuration key, e.g. cmf_menu
        // ...
        'persistence' => array(
            'phpcr' => null, // use default configuration
            // or
            'phpcr' => true, // straight way
            // or
            'phpcr' => array(
                'manager' => '...', // or any other option under 'phpcr'
            ),
        ),
    ));
    
manager_name

type: string default: null

The name of the Doctrine Manager to use. null tells the manager registry to retrieve the default manager.

If the CoreBundle is registered, this will default to the value of cmf_core.persistence.phpcr.manager_name.

translation_domain

type: string default: messages

The translation domain to use when translating the title and description template. See Defining a Title and Description Template for more information.

title

type: string default: null

The title template, read here about the usage.

description

type: string default: null

The description template, read here about the usage.

original_route_pattern

type: string default: canonical

The original route strategy to use when multiple routes have the same content. Can be one of canonical or redirect.

content_listener

New in version 1.2: The content_listener configuration key was introduced in SeoBundle 1.2.

enabled

type: boolean default: true

Whether or not the The ContentListener should be loaded.

content_key

type: string default: null (or DynamicRouter::CONTENT_KEY when RoutingBundle is enabled)

The name of the request attribute which contains the content object. This is used by the ContentListener to extract SEO information automatically. If the RoutingBundle is present, this defaults to DynamicRouter::CONTENT_KEY (which evaluates to contentDocument), otherwise you must define this manually or disable the content listener.

New in version 1.2: In versions of the SeoBundle prior to 1.2, the content_key was configured directly in the cmf_seo root.

sitemap

New in version 1.2: Support for sitemaps was introduced in version 1.2 of the SeoBundle.

  • YAML
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    # app/config/config.yml
    cmf_seo:
        sitemap:
            enabled: true
            defaults:
                default_change_frequency: always
                templates:
                    html: CmfSeoBundle:Sitemap:index.html.twig
                    xml: CmfSeoBundle:Sitemap:index.xml.twig
            configurations:
                sitemap: ~
    
  • XML
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    <!-- app/config/config.xml -->
    <?xml version="1.0" encoding="UTF-8" ?>
    <container xmlns="http://symfony.com/schema/dic/services">
    
        <config xmlns="http://example.org/schema/dic/cmf_seo">
            <sitemap enabled="true">
                <defaults>
                    <template format="html">CmfSeoBundle:Sitemap:index.html.twig</template>
                    <template format="xml">CmfSeoBundle:Sitemap:index.xml.twig</template>
                </defaults>
                <configuration name="sitemap"/>
            </sitemap>
        </config>
    </container>
    
  • PHP
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    // app/config/config.php
    $container->loadFromExtension('cmf_seo', array(
        'sitemap' => array(
            'enabled' => true,
            'defaults' => array(
                'templates' => array(
                    'html' => 'CmfSeoBundle:Sitemap:index.html.twig',
                    'xml' => 'CmfSeoBundle:Sitemap:index.xml.twig',
                ),
            ),
            'configurations' => array(
                'sitemap' => null,
            ),
        ),
    ));
    

enabled

type: boolean default: false

Whether or not the Building Sitemaps should be loaded. As soon as you configure anything else in the sitemap section, this defaults to true.

defaults

Contains default configuration that applies to all sitemaps.

configurations

Contains the list of sitemaps that should exist. Each sitemap can overwrite default configuration. If not specified, a sitemap called "sitemap" exists.

default_change_frequency

type: enum default: always allowed values: 'always', 'hourly', 'daily', 'weekly', 'monthly', 'yearly', 'never'

Specify the change frequency for UrlInformation that do not have one explicitly set.

templates

type: hashmap default: templates for html and xml

This hashmap specifies which template to use for the sitemap in each format. By default, you have:

  • html: CmfSeoBundle:Sitemap:index.html.twig
  • xml: CmfSeoBundle:Sitemap:index.xml.twig

sonata_admin_extension

If set to true, the Sonata Admin Extension provided by the SeoBundle is activated.

enabled

type: enum valid values true|false|auto default: auto

If true, the Sonata Admin Extension will be activated. If set to auto, it is activated only if the SonataPhpcrAdminBundle is present.

If the CoreBundle is registered, this will default to the value of cmf_core.persistence.phpcr.use_sonata_admin.

form_group

type: string default: form.group_seo

The name of the form group of the group provided by the Sonata Admin Extension.

form

data_class

seo_metadata

New in version 1.2: The seo_metadata setting was introduced in version 1.2.

type: string default: Symfony\Cmf\Bundle\SeoBundle\Model\SeoMetadata

Configures the class to use when creating new SeoMetadata objects using the SeoMetadata form type.

When the phpcr persistence layer is enabled, this defaults to Symfony\Cmf\Bundle\SeoBundle\Doctrine\Phpcr\SeoMetadata.

error

New in version 1.2: The error settings were introduced in SeoBundle 1.2.

Learn more about error pages in "Displaying Relevant Pages in Error Pages".

enable_parent_provider

type: boolean default: false

Whether the parent suggestion provider should be enabled.

enable_sibling_provider

type: boolean default: false

Whether the sibling suggestion provider should be enabled.

templates

type: array default: { html: 'CmfSeoBundle:Exception:error.html.twig' }

A list of templates to use for the custom error page. By default, only the HTML format is configured. The default Symfony exception controller will be used for the other formats.

exclusion_rules

type: array

To specify exclusion rules for pages that shouldn't be handled by the custom exception controller. In these cases, the default Symfony exception controller will be used instead.

Exclusion rules allow to match the following fields:

  • path
  • host
  • methods
  • ips

For instance, to not use the special exception controller for the /admin routes, use:

  • YAML
    1
    2
    3
    4
    5
    # app/config/config.yml
    cmf_seo:
        error:
            exclusion_rules:
                - { path: ^/admin }
    
  • XML
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    <!-- app/config/config.xml -->
    <?xml version="1.0" encoding="UTF-8" ?>
    <container xmlns="http://symfony.com/schema/dic/services"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
            http://cmf.symfony.com/schema/dic/seo http://cmf.symfony.com/schema/dic/seo/seo-1.0.xsd"
    >
    
        <config xmlns="http://symfony.com/schema/dic/seo">
            <error>
                <exclusion-rule path="^/admin" />
            </error>
        </config>
    </container>
    
  • PHP
    1
    2
    3
    4
    5
    6
    7
    8
    // app/config/config.php
    $container->loadFromExtension('cmf_seo', array(
        'error' => array(
            'exclusion_rules' => array(
                array('path' => '^/admin'),
            ),
        ),
    ));
    

alternate_locale

New in version 1.1: Support for alternate locales was added in version 1.1 of the SeoBundle.

  • YAML
    1
    2
    3
    4
    5
    # app/config/config.yml
    cmf_seo:
        alternate_locale:
            enabled: true
            provider_id: app.alternate_locale.provider
    
  • XML
    1
    2
    3
    4
    5
    6
    7
    <!-- app/config/config.xml -->
    <?xml version="1.0" encoding="UTF-8" ?>
    <container xmlns="http://symfony.com/schema/dic/services">
        <config xmlns="http://cmf.symfony.com/schema/dic/seo">
            <alternate-locale  enabled="true" provider-id="app.alternate_locale.provider" />
        </config>
    </container>
    
  • PHP
    1
    2
    3
    4
    5
    6
    $container->loadFromExtension('cmf_seo', array(
        'alternate_locale' => array (
            'enabled' => true,
            'provider_id' => app.alternate_locale.provider,
        ),
    ));
    

enabled

type: boolean default: true

Whether or not the the Alternate Locales Support should be loaded

provider_id

type: string default: null

Specify the service id of a custom AlternateLocaleProvider.

This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.