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

added docs on the slideshow block #104

Merged
merged 11 commits into from May 30, 2013
3 changes: 3 additions & 0 deletions bundles/block.rst
Expand Up @@ -218,6 +218,9 @@ Also the BlockBundle has more specific blocks:
* RssBlock: This block extends the ActionBlock: the block document saves the feed url and the controller action fetches
the feed items. The default implementation uses the `EkoFeedBundle <https://github.com/eko/FeedBundle>`_ to read the
feed items.
* SlideshowBlock / SlideshowItemBlock: Blocks for helping the management of slideshows in the backend. Note that this
block doesn't provide any JS to make the slideshow work in the frontend - Feel free to use your favourite JS library to do
this.
Copy link
Member

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"... ?


Examples
--------
Expand Down
79 changes: 78 additions & 1 deletion bundles/block/types.rst
Expand Up @@ -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
--------
Copy link
Member

Choose a reason for hiding this comment

The 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.

Copy link
Member

Choose a reason for hiding this comment

The 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();
Copy link
Member

Choose a reason for hiding this comment

The 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();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these 2 classes (Image and File) are missing namespaces aswell.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

$image->setFile($file);
$mySlideshowItem->setImage($image);

Render the slideshow
`````````````
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be ~ instead of a backtrick


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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's twig code, you should use .. code-block:: jinja


{{ 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's yaml code, use .. code-block:: yaml


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.
Copy link
Member

Choose a reason for hiding this comment

The 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.