Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Commit 6c5a8e0

Browse files
committed
Reread Quick tour
1 parent 2df1224 commit 6c5a8e0

10 files changed

+145
-55
lines changed
53 KB
Loading
-1.35 KB
Loading
-52 Bytes
Loading
11.6 KB
Loading
-8.61 KB
Loading
-7.44 KB
Loading

quick_tour/the_big_picture.rst

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,11 @@ Setting up the Database
5151
~~~~~~~~~~~~~~~~~~~~~~~
5252

5353
Now, the only thing left to do is setting up the database. This is not
54-
something you are used to doing when creating Symfony applications, but to make a
55-
lot of things configurable using an admin, the Symfony CMF needs a database.
54+
something you are used to doing when creating Symfony applications, but the
55+
Symfony CMF needs a database in order to make a lot of things configurable
56+
using an admin interface.
5657

57-
To get quickly started, it is expected that you have enabled the sqlite
58+
To quickly get started, it is expected that you have enabled the sqlite
5859
extension. After that, run these commands:
5960

6061
.. code-block:: bash
@@ -67,7 +68,7 @@ extension. After that, run these commands:
6768
.. tip::
6869

6970
You are going to learn more about the Database layer of the Symfony CMF
70-
later in the Quick Tour.
71+
:doc:`in the next chapter of the Quick Tour <the_model>`.
7172

7273
.. seealso::
7374

@@ -81,9 +82,9 @@ The Request Flow
8182

8283
When you have at least PHP 5.4, use the ``server:run`` command to run a
8384
local server for the demo. Otherwise, use a localhost and prefix the URLs
84-
with ``/path-to-project/web/app_dev.php/``.
85+
in this document with ``/path-to-project/web/app_dev.php/``.
8586

86-
Now the standard edition is ready to use, navigate to the homepage
87+
Now, the Standard Edition is ready to use. Navigate to the homepage
8788
(``http://localhost:8000/``) to see the demo:
8889

8990
.. image:: ../_images/quick_tour/big-picture-home.png
@@ -93,7 +94,7 @@ closer look at the request flow for a Symfony CMF application:
9394

9495
.. image:: ../_images/quick_tour/request_flow.png
9596

96-
First of all, you see a typical symfony request flow following the white
97+
First of all, you see a typical Symfony request flow following the white
9798
blocks. It creates a ``Request`` object which will be passed to a router,
9899
which executes the controller and that controller uses models to generate a
99100
view to put in the response.
@@ -140,7 +141,7 @@ object.
140141

141142
.. note::
142143

143-
You'll learn more about the router in the next chapter of the Quick Tour.
144+
You'll learn more about the router :doc:`further in the Quick Tour <the_router>`.
144145

145146
The Controller
146147
~~~~~~~~~~~~~~
@@ -167,17 +168,17 @@ Adding a New Page
167168
Now you know the request flow, you can start adding a new page. In the Symfony
168169
CMF Standard Edition, the data is stored in data files, which are loaded when
169170
executing the ``doctrine:phpcr:fixtures:load`` command. To add a new page, you
170-
just need to edit such a data file, which is located in the ``Resources/data``
171-
directory:
171+
just need to edit such a data file, which is located in the
172+
``src/Acme/DemoBundle/Resources/data`` directory:
172173

173174
.. code-block:: yaml
174175
175-
# src/Acme/MainBundle/Resources/data/page.yml
176-
static:
176+
# src/Acme/MainBundle/Resources/data/pages.yml
177+
Symfony\Cmf\Bundle\SimpleCmsBundle\Doctrine\Phpcr\Page:
177178
# ...
178179
179180
quick_tour:
180-
name: "quick_tour"
181+
id: /cms/simple/quick_tour
181182
label: "Quick Tour"
182183
title: "Reading the Quick Tour"
183184
body: "I've added this page while reading the quick tour"
@@ -190,7 +191,11 @@ the changes on the database and after refreshing, you can see your new page!
190191
Live Editing
191192
------------
192193

193-
You may already noticed the big black bar at the top of the site:
194+
Now is the time you become an admin of this site and editing the content using
195+
the Web Interface. To do this click on "Admin Login" and use the provided
196+
credentials.
197+
198+
You'll see that you have a new bar at the top of the page:
194199

195200
.. image:: ../_images/quick_tour/big-picture-createjs-bar.png
196201

quick_tour/the_model.rst

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,25 +36,24 @@ The result will be the PHPCR tree:
3636
.. code-block:: text
3737
3838
ROOT:
39-
cms:
39+
cms:
40+
content:
41+
blocks:
42+
hero_unit:
43+
quick_tour:
44+
configure:
45+
demo:
4046
simple:
41-
about:
42-
contact:
43-
map:
44-
team:
45-
quick_tour:
46-
dynamic:
47-
docs:
48-
demo:
49-
demo_redirect:
50-
hardcoded_dynamic:
51-
hardcoded_static:
47+
home:
48+
demo:
49+
quick_tour:
50+
login:
51+
menu:
5252
5353
Each data is called a *node* in PHPCR. In this tree, there are 13 nodes and
5454
one ROOT node (created by PHPCR). You may have already seen the document you
5555
created in the previous section, it's called ``quick_tour`` (and it's path is
56-
``/cms/simple/quick_tour``). When using the SimpleCmsBundle, all nodes are
57-
stored in the ``/cms/simple`` path.
56+
``/cms/simple/quick_tour``).
5857

5958
Each node has properties, which contain the data. The content, title and label
6059
you set for your page are saved in such properties for the ``quick_tour``
@@ -63,7 +62,7 @@ dump command.
6362

6463
.. note::
6564

66-
Previously, the PHPCR tree was compared with a FileSystem. While this
65+
Previously, the PHPCR tree was compared with a Filesystem. While this
6766
gives you a good imagine of what happends, it's not the truth. You can
6867
better compare it to an XML file, where each node is an element and its
6968
properties are attributes.
@@ -85,10 +84,10 @@ a page by using a yaml file which was parsed by the SimpleCmsBundle. This
8584
time, you'll create a page by doing it yourself.
8685

8786
First, you have to create a new DataFixture to add your new page. You do this
88-
by creating a new class in the AcmeMainBundle::
87+
by creating a new class in the AcmeDemoBundle::
8988

90-
// src/Acme/MainBundle/DataFixtures/PHPCR/LoadPageData.php
91-
namespace Acme\MainBundle\DataFixtures\PHPCR;
89+
// src/Acme/DemoBundle/DataFixtures/PHPCR/LoadPageData.php
90+
namespace Acme\DemoBundle\DataFixtures\PHPCR;
9291

9392
use Doctrine\Common\Persistence\ObjectManager;
9493
use Doctrine\Common\DataFixtures\FixtureInterface;

quick_tour/the_router.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ new routes in ``/cms/routes``:
146146
147147
Now you can add a new ``Route`` to the tree using Doctrine::
148148

149-
// src/Acme/MainBundle/DataFixtures/PHPCR/LoadRoutingData.php
150-
namespace Acme\MainBundle\DataFixtures\PHPCR;
149+
// src/Acme/DemoBundle/DataFixtures/PHPCR/LoadRoutingData.php
150+
namespace Acme\DemoBundle\DataFixtures\PHPCR;
151151

152152
use Doctrine\Common\Persistence\ObjectManager;
153153
use Doctrine\Common\DataFixtures\FixtureInterface;
@@ -175,7 +175,7 @@ Now you can add a new ``Route`` to the tree using Doctrine::
175175
}
176176
}
177177

178-
This creates a new node called ``/cms/routes/new-route`` which will display
178+
This creates a new node called ``/cms/routes/new-route``, which will display
179179
our ``quick_tour`` page when you go to ``/new-route``.
180180

181181
.. tip::

quick_tour/the_third_party_bundles.rst

Lines changed: 106 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,27 @@ You're still here? You already learned the basics of the Symfony CMF and you
88
just wanted to learn more and more? Then you can read this chapter! This
99
chapter will walk you quickly through some other CMF bundles. Most of the
1010
other bundles are based on the shoulders of some giants, like the KnpMenuBundle_
11-
or SonataBlockBundle_.
11+
or SonataAdminBundle_.
1212

1313
The MenuBundle
1414
--------------
1515

1616
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:
1919

2020
.. code-block:: html+jinja
2121

22-
<!-- src/Acme/MainBundle/Resources/views/layout.html.twig -->
22+
<!-- src/Acme/DemoBundle/Resources/views/layout.html.twig -->
2323

2424
<!-- ... -->
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+
<!-- ... -->
3930
</div>
40-
</div>
31+
</nav>
4132

4233
As you can see, the menu is rendered by the ``knp_menu_render`` tag. This
4334
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
6253
the CreatePHP_ library (which uses the `Create.js`_ library) into Symfony2
6354
using the FOSRestBundle_.
6455

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.
66150

67151
Sonata Admin
68152
------------
@@ -134,8 +218,10 @@ the Symfony CMF!
134218

135219
.. _KnpMenuBundle: https://github.com/KnpLabs/KnpMenuBundle
136220
.. _SonataBlockBundle: http://sonata-project.org/bundles/block/master/doc/index.html
221+
.. _SonataSeoBundle: http://sonata-project.org/bundles/seo/master/doc/index.html
137222
.. _CreatePHP: http://demo.createphp.org/
138223
.. _`Create.js`: http://createjs.org/
139224
.. _FOSRestBundle: https://github.com/friendsofsymfony/FOSRestBundle
140225
.. _SonataAdminBundle: http://sonata-project.org/bundles/admin/master/doc/index.html
141226
.. _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

Comments
 (0)