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

Commit 6f21e4b

Browse files
committed
Moved tutorial to its own section
1 parent 9b9d701 commit 6f21e4b

12 files changed

+139
-73
lines changed

cookbook/index.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ The Cookbook
44
.. toctree::
55
:hidden:
66

7-
creating_a_cms/index
87
database/choosing_storage_layer
98
database/choosing_phpcr_implementation
109
database/running_jackrabbit

cookbook/map.rst.inc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,3 @@
1111
* :doc:`Installing the CMF Standard Edition <../book/installation>` (in the book)
1212
* :doc:`editions/cmf_sandbox`
1313
* :doc:`editions/cmf_core`
14-
15-
* :doc:`creating_a_cms/index`

index.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ implementing the philosophy of the `decoupled CMS`_.
2222
contributing/index
2323
reference/index
2424
cookbook/index
25+
tutorial/index
2526

2627
Quick Tour
2728
----------
@@ -54,6 +55,24 @@ will typically want to keep this close at hand.
5455
book/static_content
5556
book/structuring_content
5657

58+
Tutorial
59+
--------
60+
61+
The tutorial guides you through all features of the CMF. It uses a step-by-step
62+
way to create a complete website build from the ground up with the CMF.
63+
64+
.. toctree::
65+
:maxdepth: 1
66+
67+
tutorial/introduction
68+
tutorial/getting-started
69+
tutorial/auto-routing
70+
tutorial/sonata-admin
71+
tutorial/content-to-controllers
72+
tutorial/the-frontend
73+
tutorial/make-homepage
74+
tutorial/conclusion
75+
5776
Bundles
5877
-------
5978

cookbook/creating_a_cms/auto-routing.rst renamed to tutorial/auto-routing.rst

Lines changed: 75 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
Routing and Automatic Routing
2-
-----------------------------
2+
=============================
33

44
The routes (URIs) to your content will be automatically created and updated
55
using the RoutingAutoBundle. This bundle uses a configuration language to
66
specify automatic creation of routes, which can be a bit hard to grasp the
77
first time you see it.
88

99
For a full explanation refer to the
10-
:doc:`../../bundles/routing_auto/index`.
10+
:doc:`RoutingAutoBundle <../bundles/routing_auto/introduction>`.
1111

1212
In summary, you will configure the auto routing system to create a new auto
1313
routing document in the routing tree for every post or content created. The
1414
new route will be linked back to the target content:
1515

16-
.. image:: ../../_images/cookbook/basic-cms-objects.png
16+
.. image:: ../_images/cookbook/basic-cms-objects.png
1717

1818
The paths above represent the path in the PHPCR-ODM document tree. In the next
1919
section you will define ``/cms/routes`` as the base path for routes, and subsequently
@@ -24,10 +24,10 @@ the contents will be available at the following URIs:
2424
* etc.
2525

2626
Installation
27-
~~~~~~~~~~~~
27+
------------
2828

29-
Ensure that you installed the RoutingAutoBundle package as detailed in the :ref:`gettingstarted_installadditionbundles`
30-
section.
29+
Ensure that you installed the RoutingAutoBundle package as detailed in the
30+
:ref:`gettingstarted_installadditionbundles` section.
3131

3232
Enable the routing bundles to your kernel::
3333

@@ -51,7 +51,7 @@ Enable the routing bundles to your kernel::
5151
`symfony-cmf/routing-auto-bundle` depends on it.
5252

5353
Enable the Dynamic Router
54-
~~~~~~~~~~~~~~~~~~~~~~~~~
54+
-------------------------
5555

5656
The RoutingAutoBundle uses the CMF `RoutingBundle`_ which enables routes to
5757
be provided from a database (in addition to being provided from
@@ -119,41 +119,91 @@ This will:
119119
can be found at ``/cms/routes``.
120120

121121
Auto Routing Configuration
122-
~~~~~~~~~~~~~~~~~~~~~~~~~~
122+
--------------------------
123123

124124
First you need to configure the auto routing bundle:
125125

126-
.. code-block:: yaml
126+
.. configuration-block::
127+
128+
.. code-block:: yaml
129+
130+
# app/config/config.yml
131+
cmf_routing_auto:
132+
persistence:
133+
phpcr:
134+
enabled: true
135+
136+
.. code-block:: xml
137+
138+
<!-- app/config/config.xml -->
139+
<container xmlns="http://symfony.com/schema/dic/services">
140+
<config xmlns="http://cmf.symfony.com/schema/dic/routing_auto">
141+
<persistence>
142+
<phpcr />
143+
</persistence>
144+
</config>
145+
</container>
146+
147+
.. code-block:: php
148+
149+
// app/config/config.php
150+
$container->loadFromExtension('cmf_routing_auto', array(
151+
'persistence' => array(
152+
'phpcr' => array(
153+
'enabled' => true,
154+
),
155+
),
156+
));
127157
128-
cmf_routing_auto:
129-
persistence:
130-
phpcr:
131-
enabled: true
132158
133159
The above configures the RoutingAutoBundle to work with PHPCR-ODM.
134160

135161
You can now proceed to mapping your documents, create the following in your
136162
*bundles* configuration directory:
137163

138-
.. code-block:: yaml
164+
.. configuration-block::
165+
166+
.. code-block:: yaml
167+
168+
# src/Acme/BasicCmsBundle/Resources/config/cmf_routing_auto.yml
169+
Acme\BasicCmsBundle\Document\Page:
170+
uri_schema: /page/{title}
171+
token_providers:
172+
title: [content_method, { method: getTitle }]
173+
174+
Acme\BasicCmsBundle\Document\Post:
175+
uri_schema: /post/{date}/{title}
176+
token_providers:
177+
date: [content_datetime, { method: getDate }]
178+
title: [content_method, { method: getTitle }]
179+
180+
.. code-block:: xml
181+
182+
<!-- src/Acme/BasicCmsBundle/Resources/config/cmf_routing_auto.xml -->
183+
<auto-mapping xmlns="http://cmf.symfony.com/schema/routing_auto">
184+
<mapping class="Acme\BasicCmsBundle\Document\Page"
185+
uri-schema="/page/{title}">
186+
187+
<token-provider token="title" name="content_method">
188+
<option name="method">getTitle</option>
189+
</token-provider>
190+
</mapping>
139191
140-
# src/Acme/BasicCmsBundle/Resources/config/cmf_routing_auto.yml
141-
Acme\BasicCmsBundle\Document\Page:
142-
uri_schema: /page/{title}
143-
token_providers:
144-
title: [content_method, { method: getTitle } ]
192+
<mapping class="Acme\BasicCmsBundle\Document\Post"
193+
extends="Acme\BasicCmsBundle\Document\Page"
194+
uri-schema="/post/{date}/{title}">
145195
146-
Acme\BasicCmsBundle\Document\Post:
147-
uri_schema: /post/{date}/{title}
148-
token_providers:
149-
date: [content_datetime, { method: getDate }
150-
title: [content_method, { method: getTitle }]
196+
<token-provider token="date" name="content_datetime">
197+
<option name="method">getDate</option>
198+
</token-provider>
199+
</mapping>
200+
</auto-mapping>
151201
152202
.. note::
153203

154204
RoutingAutoBundle mapping bundles are registered automatically when they are named
155205
as above, you may alternatively explicitly declare from where the mappings should be loaded,
156-
see the :doc:`../../bundles/routing_auto/index` documentation for more information.
206+
see the :doc:`../bundles/routing_auto/introduction` documentation for more information.
157207

158208
This will configure the routing auto system to automatically create and update
159209
route documents for both the ``Page`` and ``Post`` documents.

cookbook/creating_a_cms/conclusion.rst renamed to tutorial/conclusion.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Conclusion
2-
----------
2+
==========
33

44
And thats it! Well done. You have created a very minimum but functional
55
CMS which can act as a good foundation for larger projects!

cookbook/creating_a_cms/content-to-controllers.rst renamed to tutorial/content-to-controllers.rst

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
Controllers and Templates
2-
-------------------------
2+
=========================
33

44
Make your content route aware
5-
.............................
5+
-----------------------------
66

7-
In the :doc:`getting-started` section you defined your `Post` and `Page` documents as
8-
implementing the `RoutesReferrersReadInterface`. This interface enables the routing system
7+
In the :doc:`getting-started` section, you defined your `Post` and `Page` documents as
8+
implementing the ``RoutesReferrersReadInterface``. This interface enables the routing system
99
to retrieve routes which refer to the object implementing this interface, and this enables
1010
the system to generate a URL (for example when you use ``{{ path(mydocument) }}`` in Twig).
1111

12-
Earlier we did not have the RoutingBundle installed, so we could not add the mapping.
12+
Earlier you did not have the RoutingBundle installed, so you could not add the mapping.
1313

1414
Map the ``$routes`` property to contain a collection of all the routes which refer to this
1515
document::
1616

1717
// src/AcmeBundle/BasicCmsBundle/Document/ContentTrait.php
1818
1919
// ...
20-
2120
trait ContentTrait
2221
{
2322
// ...
@@ -36,8 +35,8 @@ document::
3635
Now you can call the method ``getRoutes`` on either ``Page`` or ``Post`` and retrieve all the
3736
routes which refer to that document ... pretty cool!
3837

39-
Route requests to a controller
40-
..............................
38+
Route Requests to a Controller
39+
------------------------------
4140

4241
Go to the URL http://127.0.0.1:8000/page/home in your browser - this should be
4342
your page, but it says that it cannot find a controller. In other words it has

cookbook/creating_a_cms/getting-started.rst renamed to tutorial/getting-started.rst

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
Getting Started
2-
---------------
2+
===============
33

44
Initializing the Project
5-
~~~~~~~~~~~~~~~~~~~~~~~~
5+
------------------------
66

7-
First, follow the generic steps in :doc:`../database/create_new_project_phpcr_odm`
7+
First, follow the generic steps in :doc:`../cookbook/database/create_new_project_phpcr_odm`
88
to create a new project using the PHPCR-ODM.
99

1010
.. _gettingstarted_installadditionbundles:
1111

1212
Install Additional Bundles
13-
..........................
13+
~~~~~~~~~~~~~~~~~~~~~~~~~~
1414

1515
The complete tutorial requires the following packages:
1616

@@ -59,12 +59,11 @@ Note that each time you modify your ``composer.json`` file you are required to
5959
run ``composer update``.
6060

6161
Initialize the Database
62-
.......................
62+
~~~~~~~~~~~~~~~~~~~~~~~
6363

64-
If you have followed the main instructions in
65-
:doc:`../../bundles/phpcr_odm/introduction` then you are using the
66-
`Doctrine DBAL Jackalope`_ PHPCR backend with MySQL and you will need to
67-
create the database:
64+
If you have followed the main instructions in :doc:`../bundles/phpcr_odm/introduction`
65+
then you are using the `Doctrine DBAL Jackalope`_ PHPCR backend with MySQL and
66+
you will need to create the database:
6867

6968
.. code-block:: bash
7069
@@ -318,7 +317,7 @@ configuration:
318317
The initializers operate at the PHPCR level, not the PHPCR-ODM level - this
319318
means that you are dealing with nodes and not documents. You do not have
320319
to understand these details right now. To learn more about PHPCR read
321-
:doc:`../database/choosing_storage_layer`.
320+
:doc:`../cookbook/database/choosing_storage_layer`.
322321

323322
The initalizers will be executed automatically when you load your data
324323
fixtures (as detailed in the next section) or alternatively you can execute
File renamed without changes.

cookbook/creating_a_cms/introduction.rst renamed to tutorial/introduction.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ Creating a Basic CMS using the RoutingAutoBundle
88
This series of articles will show you how to create a basic CMS from scratch
99
using the following bundles:
1010

11-
* :doc:`../../bundles/routing_auto/index`;
12-
* :doc:`../../bundles/phpcr_odm/index`;
13-
* :doc:`../../bundles/menu/index`;
11+
* :doc:`../bundles/routing_auto/introduction`;
12+
* :doc:`../bundles/phpcr_odm/introduction`;
13+
* :doc:`../bundles/menu/introduction`;
1414
* SonataDoctrinePHPCRAdminBundle_.
1515

1616
It is assumed that you have:
@@ -28,11 +28,11 @@ The auto routing integration will automatically create and update the routes
2828
post content documents. In addition each page content document will double up
2929
as a menu item.
3030

31-
.. image:: ../../_images/cookbook/basic-cms-intro-sketch.png
31+
.. image:: ../_images/cookbook/basic-cms-intro-sketch.png
3232

3333
.. note::
3434

35-
There exists a bundle called :doc:`../../bundles/simple_cms/index` which
35+
There exists a bundle called :doc:`../bundles/simple_cms/index` which
3636
provides a similar solution to the one proposed in this tutorial. It
3737
combines the route, menu and content into a single document and uses a
3838
custom router. The approach taken in this tutorial will combine only the menu

cookbook/creating_a_cms/make-homepage.rst renamed to tutorial/make-homepage.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
The Site Document and the Homepage
2-
----------------------------------
2+
==================================
33

44
All of your content should now be available at various URLs but your homepage
55
(http://localhost:8000) still shows the default Symfony Standard Edition
@@ -11,10 +11,10 @@ allows the user to mark a ``Page`` to act as the homepage of your CMS.
1111
.. note::
1212

1313
This is just one of many strategies for routing the homepage. For example,
14-
another option would be put a `RedirectRoute` document at `/cms/routes`.
14+
another option would be put a ``RedirectRoute`` document at ``/cms/routes``.
1515

1616
Storing the Data
17-
~~~~~~~~~~~~~~~~
17+
----------------
1818

1919
You need a document which can store data about your CMS - this will be known
2020
as the site document and it will contain a reference to the ``Page`` document
@@ -59,7 +59,7 @@ Create the site document::
5959
}
6060

6161
Initializing the Site Document
62-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
62+
------------------------------
6363

6464
Where does the ``Site`` document belong? The document hierarchy currently
6565
looks like this:
@@ -220,7 +220,7 @@ and verify that the ``cms`` node has been created correctly, using the
220220
initialization choices take place - do whatever you prefer.
221221

222222
Create the Make Homepage Button
223-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
223+
-------------------------------
224224

225225
You will need a way to allow the administrator of your site to select which
226226
page should act as the homepage. You will modify the ``PageAdmin`` class so
@@ -313,10 +313,10 @@ that it knows the edit page is requested, it retrieves the *subject* from the ad
313313
class which is the ``Page`` currently being edited, it then adds a menu item to
314314
the menu.
315315

316-
.. image:: ../../_images/cookbook/basic-cms-sonata-admin-make-homepage.png
316+
.. image:: ../_images/cookbook/basic-cms-sonata-admin-make-homepage.png
317317

318318
Routing the Homepage
319-
~~~~~~~~~~~~~~~~~~~~
319+
--------------------
320320

321321
Now that you have enabled the administrator to designate a page to be used as
322322
a homepage you need to actually make the CMS use this information to render

0 commit comments

Comments
 (0)