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

Commit aa40820

Browse files
committed
adjusted to feedback and fixed some other glitches
1 parent 927612a commit aa40820

File tree

5 files changed

+63
-32
lines changed

5 files changed

+63
-32
lines changed

bundles/block/introduction.rst

Lines changed: 60 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ individually as follows:
3333

3434
.. code-block:: yaml
3535
36-
cmf_core:
36+
cmf_block:
3737
persistence:
3838
phpcr:
3939
block_basepath: /cms/content
@@ -43,7 +43,7 @@ individually as follows:
4343
<?xml version="1.0" charset="UTF-8" ?>
4444
<container xmlns="http://symfony.com/schema/dic/services">
4545
46-
<config xmlns="http://cmf.symfony.com/schema/dic/core">
46+
<config xmlns="http://cmf.symfony.com/schema/dic/block">
4747
<persistence>
4848
<phpcr
4949
block-basepath="/cms/block"
@@ -55,7 +55,7 @@ individually as follows:
5555
5656
.. code-block:: php
5757
58-
$container->loadFromExtension('cmf_core', array(
58+
$container->loadFromExtension('cmf_block', array(
5959
'persistence' => array(
6060
'phpcr' => array(
6161
'block_basepath' => '/cms/block',
@@ -382,45 +382,51 @@ receives the block object (equivalent to a Request object) and a ``Response``
382382
object. The purpose of the ``execute`` method to set the content of the
383383
response object - typically by rendering a Twig template.
384384

385-
You can also :ref:`embed blocks in WYSIWYG content <tutorial-block-embed>`
386-
using the ``cmf_embed_blocks`` filter.
385+
.. _bundle-block-embed:
387386

388387
Embedding Blocks in WYSIWYG Content
389388
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
390389

391-
.. note::
392-
393-
This feature conflicts with the frontend editing provided by CreateBundle,
394-
editing the rendered content will store the rendered block HTML into the
395-
database. There is `discussion going on to fix this`_
396-
397390
The CmfBlockBundle provides a twig filter ``cmf_embed_blocks`` that
398391
looks through the content and looks for special tags to render blocks. To use
399-
the tag, you need to apply the ``cmf_embed_blocks`` filter to your output. If
392+
the tag, you need to apply the ``cmf_embed_blocks`` filter to your output. If
400393
you can, render your blocks directly in the template. This feature is only a
401394
cheap solution for web editors to place blocks anywhere in their HTML content.
402395
A better solution to build composed pages is to build it from blocks (there
403396
might be a CMF bundle at some point for this).
404397

405-
.. code-block:: jinja
398+
.. configuration-block::
399+
400+
.. code-block:: jinja
401+
402+
{{ page.content|cmf_embed_blocks }}
403+
404+
.. code-block:: html+php
405+
406+
<?php echo $view['blocks']->embedBlocks(
407+
$page->getContent()
408+
) ?>
406409

407-
{# template.twig.html #}
408-
{{ page.content|cmf_embed_blocks }}
410+
.. caution::
411+
412+
Make sure to only place this filter where you display the content and not
413+
where editing it, as otherwise your users would start to edit the rendered
414+
output of their blocks.
415+
This feature conflicts with the frontend editing provided by CreateBundle,
416+
as create.js operates on the rendered content as displayed to the user.
417+
There is an ongoing `discussion how to fix this`_.
409418

410-
Make sure to only place this filter where you display the content and not where
411-
editing it, as otherwise your users would start to edit the rendered output of
412-
their blocks. When you apply the filter, your users can use this tag to embed a
413-
block in their HTML content:
419+
When you apply the filter, your users can use this tag to embed a block in
420+
their content:
414421

415-
.. code-block:: html
422+
.. code-block:: text
416423
417424
%embed-block|/absolute/path/to/block|end%
418425
419426
%embed-block|local-block|end%
420427
421428
The path to the block is either absolute or relative to the current main
422-
content. The actual path to the block must be enclosed with double quotes
423-
``"``. But the prefix and postfix are configurable. The default prefix is
429+
content. The prefix and postfix are configurable. The default prefix is
424430
``%embed-block|`` and the default postfix is ``|end%``. Say you want
425431
to use ``%%%block:"/absolute/path"%%%`` then you do:
426432

@@ -432,11 +438,38 @@ to use ``%%%block:"/absolute/path"%%%`` then you do:
432438
cmf_block:
433439
twig:
434440
cmf_embed_blocks:
435-
prefix: %%%block:"
436-
postfix: "%%%
441+
prefix: '%%%block:"'
442+
postfix: '"%%%'
443+
444+
.. code-block:: xml
445+
446+
<!-- app/config/config.xml -->
447+
<?xml version="1.0" encoding="UTF-8" ?>
448+
<container xmlns="http://symfony.com/schema/dic/services">
449+
450+
<config xmlns="http://cmf.symfony.com/schema/dic/block">
451+
<twig>
452+
<cmf-embed-blocks
453+
prefix="%%%block:&quot;"
454+
postfix="&quot;%%%"
455+
/>
456+
</twig>
457+
</config>
458+
</container>
459+
460+
.. code-block:: php
461+
462+
// app/config/config.php
463+
$container->loadFromExtension('cmf_block', array(
464+
'twig' => array(
465+
'cmf_embed_blocks' => array(
466+
'prefix' => '%%%block:"',
467+
'postfix' => '"%%%',
468+
),
469+
),
470+
);
437471
438-
See also the :ref:`the configuration reference
439-
<reference-config-block-twig-cmf-embed-blocks>`.
472+
See also the :ref:`the configuration reference <reference-config-block-twig-cmf-embed-blocks>`.
440473

441474
.. caution::
442475

@@ -470,4 +503,4 @@ Read on
470503
.. _`Symfony CMF Sandbox`: https://github.com/symfony-cmf/cmf-sandbox
471504
.. _`prepended configuration`: http://symfony.com/doc/current/components/dependency_injection/compilation.html#prepending-configuration-passed-to-the-extension
472505
.. _`SonataBlockBundle`: https://github.com/sonata-project/SonataBlockBundle
473-
.. _`discussion going on to fix this`: https://github.com/symfony-cmf/BlockBundle/issues/143
506+
.. _`discussion how to fix this`: https://github.com/symfony-cmf/BlockBundle/issues/143

cookbook/creating_cms_using_cmf_and_sonata.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,8 @@ Tree Problems
210210
-------------
211211

212212
If you have not yet added anything to the content repository, the tree view
213-
will not load as it cannot find a root node. To fix this, load some data as
214-
fixtures by following ":doc:`using_blockbundle_and_contentbundle`"
213+
will not load as it cannot find a root node. Create some content to get the
214+
tree working.
215215

216216
Further Reading
217217
---------------

cookbook/index.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ The Cookbook
1111
editions/cmf_core
1212
installing_configuring_doctrine_phpcr_odm
1313
creating_cms_using_cmf_and_sonata
14-
using_blockbundle_and_contentbundle
1514
handling_multilang_documents
1615
exposing_content_via_rest
1716

cookbook/map.rst.inc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@
1111
* :doc:`create_basic_cms_auto_routing`
1212
* :doc:`installing_configuring_doctrine_phpcr_odm`
1313
* :doc:`creating_cms_using_cmf_and_sonata`
14-
* :doc:`using_blockbundle_and_contentbundle`
1514
* :doc:`handling_multilang_documents`
1615
* :doc:`exposing_content_via_rest`

reference/configuration/block.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ cmf_embed_blocks
259259
The BlockBundle provides a twig filter ``cmf_embed_blocks`` that
260260
looks through the content and looks for special tags to render blocks.
261261

262-
See :ref:`embed blocks in content <tutorial-block-embed>` for using the
262+
See :ref:`embed blocks in content <bundle-block-embed>` for using the
263263
``cmf_embed_blocks`` filter.
264264

265265
prefix

0 commit comments

Comments
 (0)