diff --git a/bundles/index.rst b/bundles/index.rst index 99e89a47..71695caa 100644 --- a/bundles/index.rst +++ b/bundles/index.rst @@ -15,7 +15,7 @@ Bundles routing_auto routing/index search - simple_cms + simple_cms/index doctrine_phpcr_admin tree_browser diff --git a/bundles/map.rst.inc b/bundles/map.rst.inc index 9c402759..df881c97 100644 --- a/bundles/map.rst.inc +++ b/bundles/map.rst.inc @@ -51,9 +51,12 @@ * :doc:`search` -* **SimpleCmsbundle** +* :doc:`simple_cms/index` - * :doc:`simple_cms` + * :doc:`simple_cms/introduction` + * :doc:`simple_cms/multilang` + * :doc:`simple_cms/rendering` + * :doc:`simple_cms/extending_page_class` * **SonataDoctrinePhpcrAdminBundle** diff --git a/bundles/routing_auto.rst b/bundles/routing_auto.rst index 2753f57e..72a0f6dc 100644 --- a/bundles/routing_auto.rst +++ b/bundles/routing_auto.rst @@ -12,7 +12,7 @@ RoutingAutoBundle The RoutingAutoBundle allows you to define automatically created routes for documents. This implies a separation of the ``Route`` and ``Content`` documents. If your needs are simple this bundle may not be for you and you -should have a look at :doc:`SimpleCmsBundle `. +should have a look at :doc:`SimpleCmsBundle `. For the sake of example, we will imagine a blog application that has two routeable contents, the blog itself, and the posts for the blog. We will call diff --git a/bundles/simple_cms.rst b/bundles/simple_cms.rst deleted file mode 100644 index 00a3c8aa..00000000 --- a/bundles/simple_cms.rst +++ /dev/null @@ -1,230 +0,0 @@ -.. index:: - single: SimpleCms; Bundles - single: SimpleCmsBundle - -SimpleCmsBundle -=============== - -.. include:: _outdate-caution.rst.inc - -The `SimpleCmsBundle`_ provides a simplistic CMS on top of the CMF components -and bundles. - -While the core CMF components focus on flexibility, the simple CMS trades away -some of that flexibility in favor of simplicity. - -The SimpleCmsBundle provides a solution to easily map content, routes and menu -items based on a single tree structure in the content repository. - -For a simple example installation of the bundle check out the -`Symfony CMF Standard Edition`_ - -You can find an introduction to the bundle in the -:doc:`Getting started <../book/simplecms>` section. - -The `CMF website`_ is another application using the SimpleCmsBundle. - -.. index:: SimpleCmsBundle, i18n - -Dependencies ------------- - -As specified in the bundle ``composer.json`` this bundle depends on most CMF -bundles. - -Configuration -------------- - -The configuration key for this bundle is ``cmf_simple_cms`` - -The ``use_menu`` option automatically enables a service to provide menus out -of the simple cms if the MenuBundle is enabled. You can also explicitly -disable it if you have the menu bundle but do not want to use the default -service, or explicitly enable to get an error if the menu bundle becomes -unavailable. - -The routing section is configuring what template or controller to use for a -content class. This is reusing what the cmf routing bundle does, please see -the corresponding -:doc:`routing configuration reference <../reference/configuration/routing>`. -It also explains the ``generic_controller``. - -See the section below for multilanguage support. - -.. configuration-block:: - - .. code-block:: yaml - - # app/config/config.yml - cmf_simple_cms: - persistence: - phpcr: - enabled: ~ - basepath: /cms/simple - manager_registry: doctrine_phpcr - manager_name: ~ - document_class: Symfony\Cmf\Bundle\SimpleCmsBundle\Doctrine\Phpcr\Page - use_sonata_admin: auto - sonata_admin: - sort: false - use_menu: auto - routing: - generic_controller: cmf_content.controller:indexAction - content_repository_id: cmf_routing.content_repository - uri_filter_regexp: - controllers_by_alias: - - # Prototype - alias: [] - controllers_by_class: - - # Prototype - alias: [] - templates_by_class: - - # Prototype - alias: [] - - -.. tip:: - - If you have the Sonata PHPCR-ODM admin bundle enabled but do *NOT* want to - show the default admin provided by this bundle, you can add the following - to your configuration - - .. configuration-block:: - - .. code-block:: yaml - - cmf_simple_cms: - persistence: - phpcr: - sonata_admin: false - -Multi-language support ----------------------- - -Setting ``addLocalePattern`` to ``true`` in ``Symfony\Cmf\Bundle\SimpleCmsBundle\Doctrine\Phpcr\Page`` -document will result in prefixing the associated route with ``/{_locale}``. Using the native -translation capabilities of PHPCR ODM it is now possible to create different versions of the document -for each language that should be available on the website. - -For example:: - - // pass true as the 3rd parameter to prefix the route pattern with /{_locale} - $page = new Page(false, false, true); - - $page->setPosition($parent, 'hello-world'); - $page->setTitle('Hello World!'); - $page->setBody('Really interesting stuff...'); - $page->setLabel('Hello World'); - $dm->persist($page); - $dm->bindTranslation($page, 'en'); - - $page->setTitle('Hallo Welt!'); - $page->setBody('Super interessante Sachen...'); - $page->setLabel('Hallo Welt!'); - $dm->bindTranslation($page, 'de'); - - $dm->flush(); - -.. note:: - - Since SimpleCmsBundle only provides a single tree structure, all nodes - will have the same node name for all languages. So a url - ``http://foo.com/en/hello-world`` for english content will look like - ``http://foo.com/de/hello-world`` for german content. At times it might be most - feasible to use integers as the node names and simple append the title of - the node in the given locale as an anchor. So for example - ``http://foo.com/de/1#my title`` and ``http://foo.com/de/1#mein title``. - If you need language specific URLs, you want to use the CMF routing bundle - and content bundle directly to have a separate route document per - language. - -Rendering ---------- - -You can specify the template to render a SimpleCms page, or use a controller -where you then give the page document to the template. A simple example for -such a template is: - -.. code-block:: jinja - - {% block content %} -

{{ page.title }}

- -
{{ page.body|raw }}
- - - {% endblock %} - -If you have the CreateBundle enabled, you can also output the document with -RDFa annotations, allowing you to edit the content as well as the tags in the -frontend. The most simple form is the following twig block: - -.. code-block:: jinja - - {% block content %} - {% createphp page as="rdf" %} - {{ rdf|raw }} - {% endcreatephp %} - {% endblock %} - -If you want to control more detailed what should be shown with RDFa, see -chapter :doc:`create`. - -Extending the Page class ------------------------- - -The default Page document ``Symfony\Cmf\Bundle\SimpleCmsBundle\Doctrine\Phpcr\Page`` -is relatively simple, shipping with a handful of the most common properties -for building a typical page: title, body, tags, publish dates etc. - -If this is not enough for your project you can easily provide your own -document by extending the default Page document and explicitly setting the -configuration parameter to your own document class: - -.. configuration-block:: - - .. code-block:: yaml - - # app/config/config.yml - cmf_simple_cms: - persistence: - phpcr: - document_class: Acme\DemoBundle\Document\MySuperPage - # ... - -Alternatively, the default Page document contains an ``extras`` property. This -is a key - value store (where value must be string or null) which can be used -for small trivial additions, without having to extend the default Page -document. - -For example:: - - $page = new Page(); - - $page->setTitle('Hello World!'); - $page->setBody('Really interesting stuff...'); - $page->setLabel('Hello World'); - - // set extras - $extras = array( - 'subtext' => 'Add CMS functionality to applications built with the Symfony2 PHP framework.', - 'headline-icon' => 'exclamation.png', - ); - - $page->setExtras($extras); - - $documentManager->persist($page); - -These properties can then be accessed in your controller or templates via the -``getExtras()`` or ``getExtra($key)`` methods. - -.. _`SimpleCmsBundle`: https://github.com/symfony-cmf/SimpleCmsBundle#readme -.. _`Symfony CMF Standard Edition`: https://github.com/symfony-cmf/symfony-cmf-standard -.. _`CMF website`: https://github.com/symfony-cmf/cmf-website/ diff --git a/bundles/simple_cms/extending_page_class.rst b/bundles/simple_cms/extending_page_class.rst new file mode 100644 index 00000000..bbd6a704 --- /dev/null +++ b/bundles/simple_cms/extending_page_class.rst @@ -0,0 +1,80 @@ +.. index:: + single: Extending Page; SimpleCmsBundle + +Extending the Page class +------------------------ + +The default Page document (``Symfony\Cmf\Bundle\SimpleCmsBundle\Model\Page``) +is relatively simple, shipping with a handful of the most common properties +for building a typical page: title, body, tags, publish dates etc. + +If this is not enough for your project you can easily provide your own +document by extending the default ``Page`` document and explicitly setting the +configuration parameter to your own document class: + +.. configuration-block:: + + .. code-block:: yaml + + cmf_simple_cms: + persistence: + phpcr: + document_class: Acme\DemoBundle\Document\MySuperPage + + .. code-block:: xml + + + + + + + + + + + + + .. code-block:: php + + $container->loadFromExtension('cmf_simple_cms', array( + 'persistence' => array( + 'phpcr' => array( + 'document_class' => 'Acme\DemoBundle\Document\MySuperPage', + ), + ), + )); + +Alternatively, the default ``Page`` document contains an ``extras`` property. +This is a key - value store (where value must be string or ``null``) which can be +used for small trivial additions, without having to extend the default Page +document. + +For example:: + + use Symfony\Cmf\Bundle\SimpleCmsBundle\Doctrine\Phpcr\Page; + // ... + + $page = new Page(); + + $page->setTitle('Hello World!'); + $page->setBody('Really interesting stuff...'); + $page->setLabel('Hello World'); + + // set extras + $extras = array( + 'subtext' => 'Add CMS functionality to applications built with the Symfony2 PHP framework.', + 'headline-icon' => 'exclamation.png', + ); + + $page->setExtras($extras); + + $documentManager->persist($page); + +These properties can then be accessed in your controller or templates via the +``getExtras()`` or ``getExtra($key)`` methods. + +.. _`SimpleCmsBundle`: https://github.com/symfony-cmf/SimpleCmsBundle#readme +.. _`Symfony CMF Standard Edition`: https://github.com/symfony-cmf/symfony-cmf-standard +.. _`CMF website`: https://github.com/symfony-cmf/cmf-website/ diff --git a/bundles/simple_cms/index.rst b/bundles/simple_cms/index.rst new file mode 100644 index 00000000..a3f42c00 --- /dev/null +++ b/bundles/simple_cms/index.rst @@ -0,0 +1,10 @@ +SimpleCmsBundle +=============== + +.. toctree:: + :maxdepth: 2 + + introduction + multilang + rendering + extending_page_class diff --git a/bundles/simple_cms/introduction.rst b/bundles/simple_cms/introduction.rst new file mode 100644 index 00000000..b64874ed --- /dev/null +++ b/bundles/simple_cms/introduction.rst @@ -0,0 +1,44 @@ +.. index:: + single: SimpleCms; Bundles + single: SimpleCmsBundle + +SimpleCmsBundle +=============== + + The SimpleCmsBundle provides a simplistic CMS on top of the CMF components + and bundles. + +While the core CMF components focus on flexibility, the simple CMS trades away +some of that flexibility in favor of simplicity. + +The SimpleCmsBundle provides a solution to easily map content, routes and menu +items based on a single tree structure in the content repository. + +You can find an introduction to the bundle in the +:doc:`Getting started <../../book/simplecms>` section. + +The `CMF website`_ is an application using the SimpleCmsBundle. + +.. tip:: + + For a simple example installation of the bundle check out the + `Symfony CMF Standard Edition`_ + +Installation +------------ + +You can install the bundle in 2 different ways: + +* Use the official Git repository (https://github.com/symfony-cmf/SimpleCmsBundle); +* Install it via Composer (``symfony-cmf/simple-cms-bundle`` on `Packagist`_). + +Sections +-------- + +* :doc:`multilang` +* :doc:`rendering` +* :doc:`extending_page_class` + +.. _`Symfony CMF Standard Edition`: https://github.com/symfony-cmf/symfony-cmf-standard +.. _`CMF website`: https://github.com/symfony-cmf/cmf-website/ +.. _`Packagist`: https://packagist.org/packages/symfony-cmf/simple-cms-bundle diff --git a/bundles/simple_cms/multilang.rst b/bundles/simple_cms/multilang.rst new file mode 100644 index 00000000..b5b1c522 --- /dev/null +++ b/bundles/simple_cms/multilang.rst @@ -0,0 +1,51 @@ +.. index:: + single: Multi-Language; SimpleCmsBundle + +Multi-Language Support +---------------------- + +Setting ``addLocalePattern`` to ``true`` in a +``Symfony\Cmf\Bundle\SimpleCmsBundle\Doctrine\Phpcr\Page`` document will +result in prefixing the associated route with ``/{_locale}``. Using the native +translation capabilities of PHPCR ODM it is now possible to create different +versions of the document for each language that should be available on the +website. + +For example:: + + use Symfony\Cmf\Bundle\SimpleCmsBundle\Doctrine\Phpcr\Page; + + // ... + + // pass true as the 3rd parameter to prefix the route pattern with /{_locale} + $page = new Page(false, false, true); + + $page->setPosition($parent, 'hello-world'); + $page->setTitle('Hello World!'); + $page->setBody('Really interesting stuff...'); + $page->setLabel('Hello World'); + + $dm->persist($page); + $dm->bindTranslation($page, 'en'); + + $page->setTitle('Hallo Welt!'); + $page->setBody('Super interessante Sachen...'); + $page->setLabel('Hallo Welt!'); + + $dm->bindTranslation($page, 'de'); + + $dm->flush(); + +.. sidebar:: Translating the URL + + Since SimpleCmsBundle only provides a single tree structure, all nodes + will have the same node name for all languages. So a url + ``http://foo.com/en/hello-world`` for english content will look like + ``http://foo.com/de/hello-world`` for german content. + + At times it might be most feasible to use integers as the node names and + simple append the title of the node in the given locale as an anchor. So + for example ``http://foo.com/de/1#my title`` and + ``http://foo.com/de/1#mein title``. If you need language specific URLs, + you want to use the CMF RoutingBundle and ContentBundle directly to have + a separate route document per language. diff --git a/bundles/simple_cms/rendering.rst b/bundles/simple_cms/rendering.rst new file mode 100644 index 00000000..f9e1d3c0 --- /dev/null +++ b/bundles/simple_cms/rendering.rst @@ -0,0 +1,58 @@ +.. index:: + single: Rendering; SimpleCmsBundle + +Rendering +--------- + +You can specify the template to render a page by setting the +``_template`` default or by specifying the controller by setting the +``_controller`` default in the page instance. Alternatively one can +configure the template and controller also via the SimpleCmsBundle +:ref:`routing configuration `. + +A simple example for such a template could look like this: + +.. configuration-block:: + + .. code-block:: html+jinja + + {% block content -%} +

{{ page.title }}

+ +
{{ page.body|raw }}
+ +
    + {% for tag in page.tags -%} +
  • {{ tag }}
  • + {%- endfor %} +
+ {%- endblock %} + + .. code-block:: html+php + + start('content') ?> +

getTitle() ?>

+ +
getBody() ?>
+ +
    + getTags() as $tag) : ?> +
  • + +
+ stop() ?> + +If you have the CreateBundle enabled, you can also output the document with +RDFa annotations, allowing you to edit the content as well as the tags in the +frontend. The most simple form is the following twig block: + +.. code-block:: jinja + + {% block content %} + {% createphp page as="rdf" %} + {{ rdf|raw }} + {% endcreatephp %} + {% endblock %} + +If you want to control more detailed what should be shown with RDFa, see +chapter :doc:`../create`. diff --git a/index.rst b/index.rst index 48f982d9..b1519cf2 100644 --- a/index.rst +++ b/index.rst @@ -105,7 +105,7 @@ to do it? In this case the reference is the right place for you. bundles/routing/index bundles/routing_auto bundles/search - bundles/simple_cms + bundles/simple_cms/index bundles/doctrine_phpcr_admin bundles/tree_browser @@ -131,7 +131,7 @@ configuration is broken down per bundle. :maxdepth: 1 reference/configuration/routing - reference/configuration/simple-cms + reference/configuration/simple_cms Contributing ------------ diff --git a/reference/configuration/core.rst b/reference/configuration/core.rst index e6cd73f5..070d432d 100644 --- a/reference/configuration/core.rst +++ b/reference/configuration/core.rst @@ -82,7 +82,7 @@ Enabling this setting will also automatically enable the equivalent setting in t * :doc:`MenuBundle <../../bundles/menu>` * :doc:`RoutingBundle <../../bundles/routing/introduction>` * :doc:`SearchBundle <../../bundles/search>` -* :doc:`SimpleCmsBundle <../../bundles/simple_cms>` +* :doc:`SimpleCmsBundle <../../bundles/simple_cms/introduction>` * :doc:`TreeBrowserCmsBundle <../../bundles/tree_browser>` PHPCR can be enabled by multiple ways such as: @@ -141,7 +141,7 @@ Enabling this setting will also automatically enable the equivalent settings in * :doc:`MenuBundle <../../bundles/menu>` * :doc:`RoutingBundle <../../bundles/routing/introduction>` * :doc:`SearchBundle <../../bundles/search>` -* :doc:`SimpleCmsBundle <../../bundles/simple_cms>` +* :doc:`SimpleCmsBundle <../../bundles/simple_cms/introduction>` manager_registry """""""""""""""" @@ -151,7 +151,7 @@ manager_registry Enabling this setting will also automatically enable the equivalent settings in the following Bundles: * :doc:`SearchBundle <../../bundles/search>` -* :doc:`SimpleCmsBundle <../../bundles/simple_cms>` +* :doc:`SimpleCmsBundle <../../bundles/simple_cms/introduction>` manager_name """""""""""" @@ -168,7 +168,7 @@ Enabling this setting will also automatically enable the equivalent setting in t * :doc:`MenuBundle <../../bundles/menu>` * :doc:`RoutingBundle <../../bundles/routing/introduction>` * :doc:`SearchBundle <../../bundles/search>` -* :doc:`SimpleCmsBundle <../../bundles/simple_cms>` +* :doc:`SimpleCmsBundle <../../bundles/simple_cms/introduction>` use_sonata_admin """""""""""""""" @@ -185,7 +185,7 @@ Enabling this setting will also automatically enable the equivalent setting in t * :doc:`ContentBundle <../../bundles/content>` * :doc:`MenuBundle <../../bundles/menu>` * :doc:`RoutingBundle <../../bundles/routing/introduction>` -* :doc:`SimpleCmsBundle <../../bundles/simple_cms>` +* :doc:`SimpleCmsBundle <../../bundles/simple_cms/introduction>` .. _config-core-multilang: @@ -198,7 +198,7 @@ enables the ``TranslatableExtension`` for ``SonataAdminBundle``. Enabling this setting will also automatically enable the equivalent setting in the following Bundles: * :doc:`RoutingBundle <../../bundles/routing/introduction>` -* :doc:`SimpleCmsBundle <../../bundles/simple_cms>` +* :doc:`SimpleCmsBundle <../../bundles/simple_cms/introduction>` .. configuration-block:: diff --git a/reference/configuration/simple-cms.rst b/reference/configuration/simple_cms.rst similarity index 99% rename from reference/configuration/simple-cms.rst rename to reference/configuration/simple_cms.rst index efdd381c..016a0eb2 100644 --- a/reference/configuration/simple-cms.rst +++ b/reference/configuration/simple_cms.rst @@ -231,7 +231,7 @@ Configure integration with CmfMenuBundle. 'use_menu' => 'auto', )); -.. _config-simple_cms-routing: +.. _config-simple-cms-routing: routing ~~~~~~~ diff --git a/reference/index.rst b/reference/index.rst index cc3395d8..ed3b318b 100644 --- a/reference/index.rst +++ b/reference/index.rst @@ -6,5 +6,6 @@ Reference configuration/core.rst configuration/routing.rst + configuration/simple_cms.rst .. include:: map.rst.inc diff --git a/reference/map.rst.inc b/reference/map.rst.inc index 3d941357..8a986530 100644 --- a/reference/map.rst.inc +++ b/reference/map.rst.inc @@ -2,3 +2,4 @@ * :doc:`configuration/core` * :doc:`configuration/routing` + * :doc:`configuration/simple_cms`