Page 1 of 1

did it my way --> need rss syndication for custom components

Posted: Fri May 01, 2009 8:36 pm
by donmarvin
I am trying to find out how to create rss syndication for custom components, but can't find any info on this.

I see in com_content the views have a 'view.feed.php' in addition to 'view.html.php'. I created a similar file for my component but there must be more to it because I'm not getting anything.

If anyone can point me in the right direction it would be greatly appreciated! TIA.

UPDATE:

I couldn't figure out the Joomla way (looking at mod_syndicate) so I did it the easy way ;-). Would appreciate any feedback regarding what I did, if it makes sense, etc.

Created a new view in the frontend component called feed, whose tmpl is coded as follows:

Code: Select all

<?php header('Content-type: text/xml'); ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title><?php echo htmlentities(strip_tags($feedtitle)); ?></title>
        <description><?php echo htmlentities(strip_tags($feeddesc)); ?></description>
        <link><?php echo $currentDomain; ?></link>
        <copyright><?php echo htmlentities(strip_tags($copyright)); ?></copyright>
<?php foreach ($items as $item) {  ?>
            <item>
                <title><?php echo htmlentities(strip_tags($item->title)); ?></title>
                <link><?php echo htmlentities($itemlink.$item->id); ?></link>
                <description><?php echo htmlentities(strip_tags($item->description,'ENT_QUOTES')); ?></description>
                <pubDate><?php echo date( "D, d M Y H:i:s T " ,strtotime($item->publish_up) ); ?></pubDate>
            </item>
<?php } ?>
    
    </channel>
</rss><?php exit;
This rss feed validates with feedvalidator.org. What do you think, does doing it this way make sense?

Re: did it my way --> need rss syndication for custom components

Posted: Fri May 08, 2009 8:19 pm
by MrRoyce
Can't argue with success!

I've learned that struggling with trying to copy someone else's MVC implementation is pointless. They may have some tiny switch set someplace that makes the whole thing work.

Re: did it my way --> need rss syndication for custom components

Posted: Sun Dec 06, 2009 9:42 pm
by squeak251
I am trying to do something with phoca download. I did find this http://tiffanybbrown.com/2005/12/22/dyn ... nd-apache/ which shows you how to set up a simple RSS feed, however I can't get it working with phoca download, doesn't want to show the files. You need to something with the .htaccess to allow php in xml files.

Re: did it my way --> need rss syndication for custom components

Posted: Mon Dec 07, 2009 12:56 am
by donmarvin
Yeah, just add this line to your .htaccess file:

Code: Select all

AddType application/x-httpd-php.xml

Re: did it my way --> need rss syndication for custom compon

Posted: Fri Aug 17, 2012 6:28 am
by Maujb
Hi Guys,
I know it has being a long time since it was posted but I thought it would help someone else.

I managed to get the view.feed.php to work. In fact was quite simple.

STEP 1

I copied the view.feed.php from the components/com_weblinks/views/category/
into my component/com_mycomponent/views/myview/category/

STEP 2

I copied the following lines from components/com_weblinks/views/category/view.html.php

Code: Select all

$link	= '&format=feed&limitstart=';
$attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0');
$document->addHeadLink(JRoute::_($link.'&type=rss'), 'alternate', 'rel', $attribs);
$attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0');
$document->addHeadLink(JRoute::_($link.'&type=atom'), 'alternate', 'rel', $attribs);
This lines were wrapped in a 'If' statement as I don't need that conditional I just didn't include it on my view.

STEP 3 - QUICK TEST

To Test if my link was coming up I went to modules manager and created a syndicate module and assigned it to the page where I want the rss feed link to appear.

STEP 4
Check in my test site and the link was there. Perfect, progress.

STEP 5
I went back to the view.feed.php in component/com_mycomponent/views/myview/category/
and made the changes to reflect my component. For example, maybe your component don't use $name, but $title, so I made this sort of changes and all worked fine.

Hope it helps someone.

Cheers