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

Commit f39c076

Browse files
committed
Merge pull request #271 from symfony-cmf/simple-cms-bundle
restructured SimpleCmsBundle docs
2 parents 454893b + dbf8aaf commit f39c076

File tree

14 files changed

+261
-243
lines changed

14 files changed

+261
-243
lines changed

bundles/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Bundles
1515
routing_auto
1616
routing/index
1717
search
18-
simple_cms
18+
simple_cms/index
1919
doctrine_phpcr_admin
2020
tree_browser
2121

bundles/map.rst.inc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,12 @@
5151

5252
* :doc:`search`
5353

54-
* **SimpleCmsbundle**
54+
* :doc:`simple_cms/index`
5555

56-
* :doc:`simple_cms`
56+
* :doc:`simple_cms/introduction`
57+
* :doc:`simple_cms/multilang`
58+
* :doc:`simple_cms/rendering`
59+
* :doc:`simple_cms/extending_page_class`
5760

5861
* **SonataDoctrinePhpcrAdminBundle**
5962

bundles/routing_auto.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ RoutingAutoBundle
1212
The RoutingAutoBundle allows you to define automatically created routes for
1313
documents. This implies a separation of the ``Route`` and ``Content``
1414
documents. If your needs are simple this bundle may not be for you and you
15-
should have a look at :doc:`SimpleCmsBundle <simple_cms>`.
15+
should have a look at :doc:`SimpleCmsBundle <simple_cms/introduction>`.
1616

1717
For the sake of example, we will imagine a blog application that has two
1818
routeable contents, the blog itself, and the posts for the blog. We will call

bundles/simple_cms.rst

Lines changed: 0 additions & 230 deletions
This file was deleted.
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
.. index::
2+
single: Extending Page; SimpleCmsBundle
3+
4+
Extending the Page class
5+
------------------------
6+
7+
The default Page document (``Symfony\Cmf\Bundle\SimpleCmsBundle\Model\Page``)
8+
is relatively simple, shipping with a handful of the most common properties
9+
for building a typical page: title, body, tags, publish dates etc.
10+
11+
If this is not enough for your project you can easily provide your own
12+
document by extending the default ``Page`` document and explicitly setting the
13+
configuration parameter to your own document class:
14+
15+
.. configuration-block::
16+
17+
.. code-block:: yaml
18+
19+
cmf_simple_cms:
20+
persistence:
21+
phpcr:
22+
document_class: Acme\DemoBundle\Document\MySuperPage
23+
24+
.. code-block:: xml
25+
26+
<?xml version="1.0" charset="UTF-8" ?>
27+
<container xmlns="http://symfony.com/schema/dic/services">
28+
29+
<config xmlns="http://cmf.symfony.com/schema/dic/simplecms">
30+
<persistence>
31+
<phpcr
32+
document-class="Acme\DemoBundle\Document\MySuperPage"
33+
/>
34+
</persistence>
35+
</config>
36+
37+
</container>
38+
39+
.. code-block:: php
40+
41+
$container->loadFromExtension('cmf_simple_cms', array(
42+
'persistence' => array(
43+
'phpcr' => array(
44+
'document_class' => 'Acme\DemoBundle\Document\MySuperPage',
45+
),
46+
),
47+
));
48+
49+
Alternatively, the default ``Page`` document contains an ``extras`` property.
50+
This is a key - value store (where value must be string or ``null``) which can be
51+
used for small trivial additions, without having to extend the default Page
52+
document.
53+
54+
For example::
55+
56+
use Symfony\Cmf\Bundle\SimpleCmsBundle\Doctrine\Phpcr\Page;
57+
// ...
58+
59+
$page = new Page();
60+
61+
$page->setTitle('Hello World!');
62+
$page->setBody('Really interesting stuff...');
63+
$page->setLabel('Hello World');
64+
65+
// set extras
66+
$extras = array(
67+
'subtext' => 'Add CMS functionality to applications built with the Symfony2 PHP framework.',
68+
'headline-icon' => 'exclamation.png',
69+
);
70+
71+
$page->setExtras($extras);
72+
73+
$documentManager->persist($page);
74+
75+
These properties can then be accessed in your controller or templates via the
76+
``getExtras()`` or ``getExtra($key)`` methods.
77+
78+
.. _`SimpleCmsBundle`: https://github.com/symfony-cmf/SimpleCmsBundle#readme
79+
.. _`Symfony CMF Standard Edition`: https://github.com/symfony-cmf/symfony-cmf-standard
80+
.. _`CMF website`: https://github.com/symfony-cmf/cmf-website/

bundles/simple_cms/index.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
SimpleCmsBundle
2+
===============
3+
4+
.. toctree::
5+
:maxdepth: 2
6+
7+
introduction
8+
multilang
9+
rendering
10+
extending_page_class

0 commit comments

Comments
 (0)