@@ -8,36 +8,27 @@ You're still here? You already learned the basics of the Symfony CMF and you
8
8
just wanted to learn more and more? Then you can read this chapter! This
9
9
chapter will walk you quickly through some other CMF bundles. Most of the
10
10
other bundles are based on the shoulders of some giants, like the KnpMenuBundle _
11
- or SonataBlockBundle _ .
11
+ or SonataAdminBundle _ .
12
12
13
13
The MenuBundle
14
14
--------------
15
15
16
16
Let's start with the MenuBundle. If you visit the page, you can see a nice
17
- menu in the sidebar . You can find the layout view in the AcmeMainBundle.
18
- Somewhere in the middle of the document, you find this code :
17
+ menu. You can find the rendering of this menu in the layout view in the
18
+ AcmeDemoBundle :
19
19
20
20
.. code-block :: html+jinja
21
21
22
- <!-- src/Acme/MainBundle /Resources/views/layout.html.twig -->
22
+ <!-- src/Acme/DemoBundle /Resources/views/layout.html.twig -->
23
23
24
24
<!-- ... -->
25
- <div class="row">
26
- <div id="content-container" class="span12 boxed">
27
- <div class="row">
28
- <div id="navigation" class="span3">
29
- <div class="well">
30
- {% block navigation %}
31
- <h2>Navigation</h2>
32
- {{ knp_menu_render('simple') }}
33
- {% endblock %}
34
- </div>
35
- </div>
36
-
37
- <!-- ... -->
38
- </div>
25
+ <nav class="navbar navbar-inverse page__nav" role="navigation">
26
+ <div class="container-fluid">
27
+ {{ knp_menu_render('simple', {'template': 'AcmeDemoBundle:Menu: bootstrap.html.twig', 'currentClass': 'active'}) }}
28
+
29
+ <!-- ... -->
39
30
</div>
40
- </div >
31
+ </nav >
41
32
42
33
As you can see, the menu is rendered by the ``knp_menu_render `` tag. This
43
34
seems a bit a strange, we are talking about the CmfMenuBundle and not the
@@ -62,7 +53,100 @@ You've already seen this bundle in the first chapter. This bundle integrates
62
53
the CreatePHP _ library (which uses the `Create.js `_ library) into Symfony2
63
54
using the FOSRestBundle _.
64
55
65
- .. todo put an example in the SE?
56
+ The Create.js library works using a REST layer. All elements on a page get
57
+ `RDFa Mappings `_, which tells Create.js how to map the element to the document.
58
+ When you save the page, the new content is passed to the REST api and saved in
59
+ the database.
60
+
61
+ Rendering content with RDFa mappings can be very easy, as you can see in the
62
+ Standard Edition:
63
+
64
+ .. code-block :: html+jinja
65
+
66
+ {% block main %}
67
+ {% createphp cmfMainContent as="rdf" %}
68
+ {{ rdf|raw }}
69
+ {% endcreatephp %}
70
+ {% endblock %}
71
+
72
+ This will output the content object using `<div> ` elements. You can also
73
+ customize this completely by using the ``createphp_* `` functions.
74
+
75
+ The BlockBundle
76
+ ---------------
77
+
78
+ If you visit the homepage of the Standard Edition, you'll see three blocks:
79
+
80
+ .. image :: ../_images/quick_tour/3rd-party-bundles-homepage.png
81
+
82
+ These blocks can be edited and used on their own. These blocks are provided by
83
+ the BlockBundle, which is a tiny layer on top of the SonataBlockBundle _. It
84
+ provides the ability to store the blocks using PHPCR and it adds some commonly
85
+ used blocks.
86
+
87
+ The three blocks in the Standard Edition are custom blocks. A block is handled
88
+ by a block service. You can find this service in the
89
+ ``Acme\DemoBundle\Block\UnitBlockService `` class. Since the blocks are
90
+ persisted using PHPCR, it also needs a block document, which is located in
91
+ ``Acme\DemoBundle\Document\UnitBlock ``.
92
+
93
+ The SeoBundle
94
+ -------------
95
+
96
+ There is also a SeoBundle. This bundle is build on top of the
97
+ SonataSeoBundle _. It provides a way to extract SEO information from a document
98
+ and to make SEO information editable using an admin.
99
+
100
+ To integrate the SeoBundle into the Standard Edition, you must register both
101
+ bundles in the ``AppKernel ``::
102
+
103
+ // app/AppKernel.php
104
+
105
+ // ...
106
+ public function registerBundles()
107
+ {
108
+ $bundles = array(
109
+ // ...
110
+ new Sonata\SeoBundle\SonataSeoBundle(),
111
+ new Symfony\Cmf\Bundle\SeoBundle\CmfSeoBundle(),
112
+ );
113
+ // ...
114
+ }
115
+
116
+ Now, you can configure a standard title. This is the title that is used when
117
+ the CmfSeoBundle can extract the title from a content object:
118
+
119
+ .. code-block :: yaml
120
+
121
+ # app/config/config.yml
122
+ cmf_seo :
123
+ title : " %%content_title%% | Standard Edition"
124
+
125
+ The ``%%content_title%% `` will be replaced by the title extracted from the
126
+ content object. The last thing you need to do is using this title as the title
127
+ element. To do this, replace the ``<title> `` tag line in the
128
+ ``src/Acme/DemoBundle/Resources/views/layout.html.twig `` template with this:
129
+
130
+ .. code-block :: html+jinja
131
+
132
+ {% block title %}{% sonata_seo_title() %}{% endblock %}
133
+
134
+ Now, you can see nice titles when visiting the website.
135
+
136
+ Some pages, like the login page, don't use content objects. In these cases,
137
+ you can configure a default title:
138
+
139
+ .. code-block :: yaml
140
+
141
+ # app/config/config.yml
142
+ sonata_seo :
143
+ page :
144
+ title : Standard Edition
145
+
146
+ .. caution ::
147
+
148
+ The *default title * is configured under the ``sonata_seo `` extension, while
149
+ the *standard title * is configured under the ``cmf_seo `` extension.
66
150
67
151
Sonata Admin
68
152
------------
@@ -134,8 +218,10 @@ the Symfony CMF!
134
218
135
219
.. _KnpMenuBundle : https://github.com/KnpLabs/KnpMenuBundle
136
220
.. _SonataBlockBundle : http://sonata-project.org/bundles/block/master/doc/index.html
221
+ .. _SonataSeoBundle : http://sonata-project.org/bundles/seo/master/doc/index.html
137
222
.. _CreatePHP : http://demo.createphp.org/
138
223
.. _`Create.js` : http://createjs.org/
139
224
.. _FOSRestBundle : https://github.com/friendsofsymfony/FOSRestBundle
140
225
.. _SonataAdminBundle : http://sonata-project.org/bundles/admin/master/doc/index.html
141
226
.. _SonataDoctrinePHPCRAdminBundle : http://sonata-project.org/bundles/doctrine-phpcr-admin/master/doc/index.html
227
+ .. _`RDFa Mappings` : http://en.wikipedia.org/wiki/RDFa
0 commit comments