1. Tipos de bloque

For each purpose a different block type can be used. The general purpose blocks can be used for several solutions. The Block Bundle ships with more specific block types.

1.1. RSSBlock

The RssBlock extends the ActionBlock and allows you to read feed items and display them in a list.

Create a document:

$myRssBlock = new RssBlock();
$myRssBlock->setParentDocument($parentPage);
$myRssBlock->setName('rssBlock');
$myRssBlock->setSetting('title', 'Symfony2 CMF news');
$myRssBlock->setSetting('url', 'http://cmf.symfony.com/news.rss');
$myRssBlock->setSetting('maxItems', 3);

$documentManager->persist($myRssBlock);

Todas las opciones disponibles son:

  • url: the url of the rss feed (required)
  • title: the title for the list (default: Insert the rss title)
  • maxItems: the maximum amount of items to return to the template (default: 10)
  • template: the template to render the feed items (default: SymfonyCmfBlockBundle:Block:block_rss.html.twig)
  • ItemClass: La clase utilizada para el objetO elemento pasado a la plantilla (predefinido: SymfonyCmfBundleBlockBundleModelFeedItem)

The controller to get the feed items can also be changed:

  • define a different class for the controller service in your configuration using the DI service parameter symfony_cmf_block.rss_controller_class
  • or set the actionName of your RssBlock document

Nota

El Symfony CMF Sandbox contiene un ejemplo del RssBlock.

Bifúrcame en GitHub