This repository was archived by the owner on Sep 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 156
Add SeoBundle twig extension documentation #705
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ SeoBundle | |
extractors | ||
sitemap | ||
configuration | ||
twig |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dbu I reworded this per your comment. |
||
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 | ||
|
||
<!-- app/Resources/views/base.html.twig --> | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
{% block metadata %} | ||
{{ sonata_seo_title() }} | ||
|
||
{{ sonata_seo_metadatas() }} | ||
{% endblock metadata %} | ||
</head> | ||
<body> | ||
<p>Some page body.</p> | ||
</body> | ||
</html> | ||
|
||
<!-- app/Resources/views/Blog/post.html.twig --> | ||
{% extends 'base.html.twig' %} | ||
|
||
{% block metadata %} | ||
{{ cmf_seo_update_metadata(post) }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dbu Removed the do, you caught me trying to be clever. |
||
{{ parent() }} | ||
{% endblock metadata %} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dbu I added this here per your comment on mentioning the twig extension