How to have DirectPHP plugin process RSS feed (for Joomla 1.5.x)?
Written by kksou   
Monday, 12 May 2008

If you have used the DirectPHP plugin to include PHP commands in content articles, you will find that these PHP commands do not get processed in the RSS feed generator that comes standard with Joomla 1.5 installation.

This article shows you how to have DirectPHP plugin process the RSS feed so that users do not see all those PHP commands in the RSS feed.

Note: the steps below are for Joomla 1.5.x. If you're using Joomla 1.0.x, please refer to How to have DirectPHP plugin process RSS feed (for Joomla 1.0.x)?.


Explanations

In the original Joomla installation, there is no plugin trigger in the RSS feed generator. When there is no trigger, none of the plugin will get called.

In order for Joomla to have DirectPHP plugin process the RSS feed, we need to add a plugin trigger.

Solutions

All you need is to add 5 lines to have DirectPHP plugin process the RSS feed!

  1. Go to the folder <Joomla root folder>/libraries/joomla/document/feed/renderer, you will see a file called rss.php.
  2. Open this file rss.php in your favorite editor.
  3. Go to around Line 110, you should see the following lines:
    if ($data->skipDays!="") {
    	$feed.= "		<skipDays>".htmlspecialchars($data->skipDays, 
    	    ENT_COMPAT, 'UTF-8')."</skipDays>\n";
    }
    
    for ($i=0; $i<count($data->items); $i++)
    {
    	$feed.= "		<item>\n";
    	$feed.= "			<title>".
    	    htmlspecialchars(strip_tags($data->items[$i]->title), 
    	    ENT_COMPAT, 'UTF-8')."</title>\n";
    	$feed.= "			<link>".$url.$data->items[$i]->link."</link>\n";
    	$feed.= "			<description><![CDATA[".
    	    $this->_relToAbs($data->items[$i]->description)."]]></description>\n";
    
    	if ($data->items[$i]->author!="") {
    	    $feed.= "			<author>".htmlspecialchars(
    		$data->items[$i]->author, ENT_COMPAT, 'UTF-8')."</author>\n";
    	}
    

  4. Now add the five lines highlighted in yellow as shown below:
  5. if ($data->skipDays!="") {
    	$feed.= "		<skipDays>".htmlspecialchars($data->skipDays, 
    	    ENT_COMPAT, 'UTF-8')."</skipDays>\n";
    }
    
    $dispatcher =& JDispatcher::getInstance();
    JPluginHelper::importPlugin('content');
    
    for ($i=0; $i<count($data->items); $i++)
    {
    	$data->items[$i]->text = $data->items[$i]->description;
    	$results=$dispatcher->trigger('onPrepareContent',
    	    array(&$data->items[$i], array(), 0));
    	$data->items[$i]->description = $data->items[$i]->text;
    
    	$feed.= "		<item>\n";
    	$feed.= "			<title>".
    	    htmlspecialchars(strip_tags($data->items[$i]->title), 
    	    ENT_COMPAT, 'UTF-8')."</title>\n";
    	$feed.= "			<link>".$url.$data->items[$i]->link."</link>\n";
    	$feed.= "			<description><![CDATA[".
    	    $this->_relToAbs($data->items[$i]->description)."]]></description>\n";
    
    	if ($data->items[$i]->author!="") {
    	    $feed.= "			<author>".htmlspecialchars(
    		$data->items[$i]->author, ENT_COMPAT, 'UTF-8')."</author>\n";
    	}
    

  6. Save and close this file.

That's it! Now try your RSS feed. Your PHP commands should now be processed in the RSS feed too!

Note

I wrote this solution for the DirectPHP plugin. But once you have added the 5 lines above, you should find that the RSS feed will get processed by ALL content plugins!



User reviews

There are no user reviews yet.

Note: You have to be a registered member to leave a comment. Free registration here.

 
< Prev   Next >

Copyright © 2006-2008. kksou.com. All Rights Reserved