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

Commit dbf8aaf

Browse files
committed
Fixed language and code
1 parent cb53c10 commit dbf8aaf

File tree

4 files changed

+71
-32
lines changed

4 files changed

+71
-32
lines changed

bundles/simple_cms/extending_page_class.rst

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1+
.. index::
2+
single: Extending Page; SimpleCmsBundle
3+
14
Extending the Page class
25
------------------------
36

4-
The default Page document ``Symfony\Cmf\Bundle\SimpleCmsBundle\Doctrine\Phpcr\Page``
7+
The default Page document (``Symfony\Cmf\Bundle\SimpleCmsBundle\Model\Page``)
58
is relatively simple, shipping with a handful of the most common properties
69
for building a typical page: title, body, tags, publish dates etc.
710

811
If this is not enough for your project you can easily provide your own
9-
document by extending the default Page document and explicitly setting the
12+
document by extending the default ``Page`` document and explicitly setting the
1013
configuration parameter to your own document class:
1114

1215
.. configuration-block::
@@ -43,13 +46,16 @@ configuration parameter to your own document class:
4346
),
4447
));
4548
46-
Alternatively, the default Page document contains an ``extras`` property. This
47-
is a key - value store (where value must be string or null) which can be used
48-
for small trivial additions, without having to extend the default Page
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
4952
document.
5053

5154
For example::
5255

56+
use Symfony\Cmf\Bundle\SimpleCmsBundle\Doctrine\Phpcr\Page;
57+
// ...
58+
5359
$page = new Page();
5460

5561
$page->setTitle('Hello World!');

bundles/simple_cms/introduction.rst

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ some of that flexibility in favor of simplicity.
1414
The SimpleCmsBundle provides a solution to easily map content, routes and menu
1515
items based on a single tree structure in the content repository.
1616

17-
For a simple example installation of the bundle check out the
18-
`Symfony CMF Standard Edition`_
19-
2017
You can find an introduction to the bundle in the
2118
:doc:`Getting started <../../book/simplecms>` section.
2219

23-
The `CMF website`_ is another application using the SimpleCmsBundle.
20+
The `CMF website`_ is an application using the SimpleCmsBundle.
21+
22+
.. tip::
23+
24+
For a simple example installation of the bundle check out the
25+
`Symfony CMF Standard Edition`_
2426

2527
Installation
2628
------------
@@ -39,4 +41,4 @@ Sections
3941

4042
.. _`Symfony CMF Standard Edition`: https://github.com/symfony-cmf/symfony-cmf-standard
4143
.. _`CMF website`: https://github.com/symfony-cmf/cmf-website/
42-
.. _`Packagist`: https://packagist.org/packages/symfony-cmf/simple-cms-bundle
44+
.. _`Packagist`: https://packagist.org/packages/symfony-cmf/simple-cms-bundle

bundles/simple_cms/multilang.rst

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,51 @@
1-
Multi-language support
1+
.. index::
2+
single: Multi-Language; SimpleCmsBundle
3+
4+
Multi-Language Support
25
----------------------
36

4-
Setting ``addLocalePattern`` to ``true`` in ``Symfony\Cmf\Bundle\SimpleCmsBundle\Doctrine\Phpcr\Page``
5-
document will result in prefixing the associated route with ``/{_locale}``. Using the native
6-
translation capabilities of PHPCR ODM it is now possible to create different versions of the document
7-
for each language that should be available on the website.
7+
Setting ``addLocalePattern`` to ``true`` in a
8+
``Symfony\Cmf\Bundle\SimpleCmsBundle\Doctrine\Phpcr\Page`` document will
9+
result in prefixing the associated route with ``/{_locale}``. Using the native
10+
translation capabilities of PHPCR ODM it is now possible to create different
11+
versions of the document for each language that should be available on the
12+
website.
813

914
For example::
1015

16+
use Symfony\Cmf\Bundle\SimpleCmsBundle\Doctrine\Phpcr\Page;
17+
18+
// ...
19+
1120
// pass true as the 3rd parameter to prefix the route pattern with /{_locale}
1221
$page = new Page(false, false, true);
1322

1423
$page->setPosition($parent, 'hello-world');
1524
$page->setTitle('Hello World!');
1625
$page->setBody('Really interesting stuff...');
1726
$page->setLabel('Hello World');
27+
1828
$dm->persist($page);
1929
$dm->bindTranslation($page, 'en');
2030

2131
$page->setTitle('Hallo Welt!');
2232
$page->setBody('Super interessante Sachen...');
2333
$page->setLabel('Hallo Welt!');
34+
2435
$dm->bindTranslation($page, 'de');
2536

2637
$dm->flush();
2738

28-
.. note::
39+
.. sidebar:: Translating the URL
2940

3041
Since SimpleCmsBundle only provides a single tree structure, all nodes
3142
will have the same node name for all languages. So a url
3243
``http://foo.com/en/hello-world`` for english content will look like
33-
``http://foo.com/de/hello-world`` for german content. At times it might be most
34-
feasible to use integers as the node names and simple append the title of
35-
the node in the given locale as an anchor. So for example
36-
``http://foo.com/de/1#my title`` and ``http://foo.com/de/1#mein title``.
37-
If you need language specific URLs, you want to use the CMF routing bundle
38-
and content bundle directly to have a separate route document per
39-
language.
44+
``http://foo.com/de/hello-world`` for german content.
45+
46+
At times it might be most feasible to use integers as the node names and
47+
simple append the title of the node in the given locale as an anchor. So
48+
for example ``http://foo.com/de/1#my title`` and
49+
``http://foo.com/de/1#mein title``. If you need language specific URLs,
50+
you want to use the CMF RoutingBundle and ContentBundle directly to have
51+
a separate route document per language.

bundles/simple_cms/rendering.rst

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
.. index::
2+
single: Rendering; SimpleCmsBundle
3+
14
Rendering
25
---------
36

@@ -9,19 +12,35 @@ configure the template and controller also via the SimpleCmsBundle
912

1013
A simple example for such a template could look like this:
1114

12-
.. code-block:: jinja
15+
.. configuration-block::
1316

14-
{% block content %}
15-
<h1>{{ page.title }}</h1>
17+
.. code-block:: html+jinja
18+
19+
{% block content -%}
20+
<h1>{{ page.title }}</h1>
1621

17-
<div>{{ page.body|raw }}</div>
22+
<div>{{ page.body|raw }}</div>
23+
24+
<ul>
25+
{% for tag in page.tags -%}
26+
<li>{{ tag }}</li>
27+
{%- endfor %}
28+
</ul>
29+
{%- endblock %}
30+
31+
.. code-block:: html+php
32+
33+
<?php $view['slots']->start('content') ?>
34+
<h1><?php $page->getTitle() ?></h1>
35+
36+
<div><?php $page->getBody() ?></div>
1837

1938
<ul>
20-
{% for tag in page.tags %}
21-
<li>{{ tag }}</li>
22-
{% endfor %}
39+
<?php foreach ($page->getTags() as $tag) : ?>
40+
<li><?php echo $tag ?></li>
41+
<?php endforeach ?>
2342
</ul>
24-
{% endblock %}
43+
<?php $view['slots']->stop() ?>
2544

2645
If you have the CreateBundle enabled, you can also output the document with
2746
RDFa annotations, allowing you to edit the content as well as the tags in the
@@ -36,4 +55,4 @@ frontend. The most simple form is the following twig block:
3655
{% endblock %}
3756
3857
If you want to control more detailed what should be shown with RDFa, see
39-
chapter :doc:`../create`.
58+
chapter :doc:`../create`.

0 commit comments

Comments
 (0)