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

For Joomla! 1.5 Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general
Forum rules
Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.
Locked
User avatar
donmarvin
Joomla! Explorer
Joomla! Explorer
Posts: 379
Joined: Sat Mar 04, 2006 2:27 pm
Location: New York
Contact:

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

Post by donmarvin » Fri May 01, 2009 8:36 pm

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?

User avatar
MrRoyce
Joomla! Ace
Joomla! Ace
Posts: 1176
Joined: Mon Oct 09, 2006 9:52 pm
Location: Tampuh Floriduh - The jewels of America's wang.
Contact:

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

Post by MrRoyce » Fri May 08, 2009 8:19 pm

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.

squeak251
Joomla! Apprentice
Joomla! Apprentice
Posts: 48
Joined: Sat Feb 14, 2009 8:22 pm

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

Post by squeak251 » Sun Dec 06, 2009 9:42 pm

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.

User avatar
donmarvin
Joomla! Explorer
Joomla! Explorer
Posts: 379
Joined: Sat Mar 04, 2006 2:27 pm
Location: New York
Contact:

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

Post by donmarvin » Mon Dec 07, 2009 12:56 am

Yeah, just add this line to your .htaccess file:

Code: Select all

AddType application/x-httpd-php.xml
http://www.iTeachMe.com
Online Learning System for Joomla!(R)

Maujb
Joomla! Apprentice
Joomla! Apprentice
Posts: 11
Joined: Fri Aug 17, 2012 6:13 am

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

Post by Maujb » Fri Aug 17, 2012 6:28 am

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


Locked

Return to “Joomla! 1.5 Coding”