added docs on the slideshow block #104
Changes from 7 commits
0afe3ac
24d17ef
760c3f7
4fa92ff
90634a1
fc23420
21a7dc2
1bfb868
e0023a2
8700330
75ebe1a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,4 +37,81 @@ The controller to get the feed items can also be changed: | |
|
||
.. note:: | ||
|
||
The `Symfony CMF Sandbox <https://github.com/symfony-cmf/cmf-sandbox>`_ contains an example of the RssBlock. | ||
The `Symfony CMF Sandbox <https://github.com/symfony-cmf/cmf-sandbox>`_ contains an example of the RssBlock. | ||
|
||
SlideshowBlock | ||
-------- | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know CMF's doc standards, but I think it's better to make the heading line as long as the heading title. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
|
||
The ``SlideshowBlock`` is just a special kind of ``ContainerBlock``, a container for the slides of a slideshow. The | ||
BlockBundle also comes with a ``SlideshowItemBlock`` which represents a very simple kind of slide, a ``SlideshowItem``, | ||
which contains an image and a label. However you are free to use whatever block you want as an item for a slideshow. | ||
You can also mix different sorts of slides in the same slideshow. | ||
|
||
Create your first slideshow | ||
````````````` | ||
|
||
.. code-block:: php | ||
|
||
// create slideshow | ||
$mySlideshow = new SlideshowBlock(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing use statement for this class |
||
$mySlideshow->setName('slideshow'); | ||
$mySlideshow->setParentDocument($parentPage); | ||
$mySlideshow->setTitle('My first Slideshow'); | ||
$documentManager->persist($mySlideshow); | ||
|
||
// add first slide to slideshow | ||
$mySlideshowItem = new SlideshowItemBlock(); | ||
$mySlideshowItem->setName('first_item'); | ||
$mySlideshowItem->setLabel('label of first item'); | ||
$mySlideshowItem->setParentDocument($mySlideshow); | ||
$manager->persist($mySlideshowItem); | ||
|
||
$file = new File(); | ||
$file->setFileContentFromFilesystem('path/to/my/image.jpg'); | ||
$image = new Image(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these 2 classes ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
$image->setFile($file); | ||
$mySlideshowItem->setImage($image); | ||
|
||
Render the slideshow | ||
````````````` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should be |
||
|
||
Rendering your slideshow is as easy as just rendering the according block in your template. Note that your document | ||
needs to have a ``SlideshowBlock`` with the name used here: | ||
|
||
.. code-block:: php | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's twig code, you should use |
||
|
||
{{ sonata_block_render({ | ||
'name': 'slideshow' | ||
}) }} | ||
|
||
Use the admin class | ||
````````````` | ||
|
||
The BlockBundle comes with admin classes for managing slideshows and slideshow items directly in SonataAdmin. All you | ||
need to do to administrate slideshows in your project is to add the following line to your sonata admin configuration: | ||
|
||
.. code-block:: php | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's yaml code, use |
||
|
||
sonata_admin: | ||
dashboard: | ||
groups: | ||
blocks: | ||
label: Blocks | ||
items: | ||
- symfony_cmf_block.slideshow_admin | ||
|
||
However, you can also integrate the slideshow administration directly in another AdminClass using | ||
``symfony_cmf_block.minimal_slideshow_admin``. Please refer to `the Sonata Admin docs | ||
<http://sonata-project.org/bundles/admin/master/doc/reference/form_types.html>`_ for further information. | ||
|
||
If you use the default template, you need to add the `LiipImagineBundle <https://github.com/liip/LiipImagineBundle>`_ | ||
to your dependencies and define a imagine filter called 'slideshow_image'. Refer to the `docs | ||
<https://github.com/liip/LiipImagineBundle/tree/master/Resources/doc>`_ for further information. | ||
|
||
Make the slideshow work in the frontend | ||
````````````` | ||
|
||
Since the BlockBundle doesn't contain anything to make the slideshow work in the frontend, you need to do this | ||
yourself. Just use your favourite JS library to make the slideshow interactive. If special markup is needed for your | ||
slideshow code to work, just override ``block_slideshow.html.twig`` and ``block_slideshow_item.html.twig`` and adapt | ||
them to your needs. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I prefer to have a trailing line at the end of the file, to avoid nasty conflicts when something is added. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
..."block does not provide any javascript to make"... ?