eko / FeedBundle

A Symfony bundle to build RSS feeds from your entities
http://vincent.composieux.fr
MIT License
141 stars 50 forks source link

Documentation #6

Closed waldo2188 closed 12 years ago

waldo2188 commented 12 years ago

Salut, Pouvez-vous expliquer comment ajouter de nouveaux champs. J'aimerai ajouter plusieurs élément "category" dans les éléments "item".

Merci.


Hy !

Can you add some explanation about the possibility of adding new field? I want to add multiple field "category" into the "item" element.

Thanks

eko commented 12 years ago

Hi,

To add a new custom field, you juste have to do something like defined in the documentation.

1. In your controller:

<?php
$feed = $this->get('eko_feed.feed.manager')->get('article');
$feed->addField(new Field('category', 'getFeedItemCategory'));

Then you have to define the getFeedItemCategory() method in your entity.

2. In your entity:

<?php
public function getFeedItemCategory()
{
    return 'Your category';
}

The category node will be displayed like that:

    <item>
        <title><![CDATA[My title]]></title>
        <description><![CDATA[My description]]></description>
        <link>http://github.com/eko/FeedBundle</link>
        <pubDate>Sat, 07 Nov 2009 16:26:58 +0100</pubDate>
        <category>My category</category>
    </item>

Does this explanation has answered your question?

waldo2188 commented 12 years ago

That's the way i've followed. But the code throw this error :

Fatal error: Call to undefined method Eko\FeedBundle\Item\ProxyItem::getFeedItemCategory() in /home/waldo/www/projetx/vendor/eko/feedbundle/Eko/FeedBundle/Formatter/Formatter.php on line 72
eko commented 12 years ago

Indeed, there is a bug adding custom fields when implementing RoutedItemInterface. I'm working on a fix as soon as possible.

Thank you for reporting this issue!

eko commented 12 years ago

This bug is now fixed, you can update sources and your custom field should work now.

Thank your for your report and have a great time with FeedBundle :)