@@ -33,7 +33,7 @@ individually as follows:
33
33
34
34
.. code-block :: yaml
35
35
36
- cmf_core :
36
+ cmf_block :
37
37
persistence :
38
38
phpcr :
39
39
block_basepath : /cms/content
@@ -43,7 +43,7 @@ individually as follows:
43
43
<?xml version =" 1.0" charset =" UTF-8" ?>
44
44
<container xmlns =" http://symfony.com/schema/dic/services" >
45
45
46
- <config xmlns =" http://cmf.symfony.com/schema/dic/core " >
46
+ <config xmlns =" http://cmf.symfony.com/schema/dic/block " >
47
47
<persistence >
48
48
<phpcr
49
49
block-basepath =" /cms/block"
@@ -55,7 +55,7 @@ individually as follows:
55
55
56
56
.. code-block :: php
57
57
58
- $container->loadFromExtension('cmf_core ', array(
58
+ $container->loadFromExtension('cmf_block ', array(
59
59
'persistence' => array(
60
60
'phpcr' => array(
61
61
'block_basepath' => '/cms/block',
@@ -382,45 +382,51 @@ receives the block object (equivalent to a Request object) and a ``Response``
382
382
object. The purpose of the ``execute `` method to set the content of the
383
383
response object - typically by rendering a Twig template.
384
384
385
- You can also :ref: `embed blocks in WYSIWYG content <tutorial-block-embed >`
386
- using the ``cmf_embed_blocks `` filter.
385
+ .. _bundle-block-embed :
387
386
388
387
Embedding Blocks in WYSIWYG Content
389
388
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
390
389
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
-
397
390
The CmfBlockBundle provides a twig filter ``cmf_embed_blocks `` that
398
391
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
400
393
you can, render your blocks directly in the template. This feature is only a
401
394
cheap solution for web editors to place blocks anywhere in their HTML content.
402
395
A better solution to build composed pages is to build it from blocks (there
403
396
might be a CMF bundle at some point for this).
404
397
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
+ ) ?>
406
409
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 `_.
409
418
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:
414
421
415
- .. code-block :: html
422
+ .. code-block :: text
416
423
417
424
%embed-block|/absolute/path/to/block|end%
418
425
419
426
%embed-block|local-block|end%
420
427
421
428
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
424
430
``%embed-block| `` and the default postfix is ``|end% ``. Say you want
425
431
to use ``%%%block:"/absolute/path"%%% `` then you do:
426
432
@@ -432,11 +438,38 @@ to use ``%%%block:"/absolute/path"%%%`` then you do:
432
438
cmf_block :
433
439
twig :
434
440
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:" "
454
+ postfix =" " %%%"
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
+ );
437
471
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 >`.
440
473
441
474
.. caution ::
442
475
@@ -470,4 +503,4 @@ Read on
470
503
.. _`Symfony CMF Sandbox` : https://github.com/symfony-cmf/cmf-sandbox
471
504
.. _`prepended configuration` : http://symfony.com/doc/current/components/dependency_injection/compilation.html#prepending-configuration-passed-to-the-extension
472
505
.. _`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
0 commit comments