diff --git a/bundles/map.rst.inc b/bundles/map.rst.inc index a5a70bf7..97d7ee1e 100644 --- a/bundles/map.rst.inc +++ b/bundles/map.rst.inc @@ -72,6 +72,7 @@ library or they introduce a complete new concept. * :doc:`seo/seo_aware` * :doc:`seo/extractors` * :doc:`seo/configuration` + * :doc:`seo/twig` * :doc:`tree_browser/index` diff --git a/bundles/seo/index.rst b/bundles/seo/index.rst index 27bf10be..e4cd788f 100644 --- a/bundles/seo/index.rst +++ b/bundles/seo/index.rst @@ -9,3 +9,4 @@ SeoBundle extractors sitemap configuration + twig diff --git a/bundles/seo/introduction.rst b/bundles/seo/introduction.rst index 97cbdaba..ca82e128 100644 --- a/bundles/seo/introduction.rst +++ b/bundles/seo/introduction.rst @@ -137,6 +137,16 @@ key in ``cmf_seo.content_key``. You may also want to disable this listener when implementing your own mechanism to extract SEO information. +The Twig Extension +~~~~~~~~~~~~~~~~~~ + +.. versionadded:: 1.2 + The twig extension was added in SeoBundle 1.2. + +This bundle provides a twig function ``cmf_seo_update_metadata`` +which lets you populate the seo page from an object. +For details on using the twig extension, read :doc:`twig`. + Extracting Metadata ~~~~~~~~~~~~~~~~~~~ diff --git a/bundles/seo/twig.rst b/bundles/seo/twig.rst new file mode 100644 index 00000000..ce2a216a --- /dev/null +++ b/bundles/seo/twig.rst @@ -0,0 +1,40 @@ +Setting Seo Metadata from Twig +============================== + +.. versionadded:: 1.2 + The twig extension was added in SeoBundle 1.2. + +This bundle provides a twig function ``cmf_seo_update_metadata`` +which lets you populate the seo page from an object. +For details on how populating the SEO page works, read :doc:`introduction`. + +You must call this function in your twig template before the calls to +``sonata_seo_title`` and ``sonata_seo_metadatas`` functions. The +recommended set up for this is to create a metadata block in your +base twig template and override it in a sub template, calling +``cmf_seo_update_metadata`` before calling ``parent()``. + +.. code-block:: html+jinja + + + + + + {% block metadata %} + {{ sonata_seo_title() }} + + {{ sonata_seo_metadatas() }} + {% endblock metadata %} + + +

Some page body.

+ + + + + {% extends 'base.html.twig' %} + + {% block metadata %} + {{ cmf_seo_update_metadata(post) }} + {{ parent() }} + {% endblock metadata %}