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

If you have used the DirectPHP plugin or Include Content Item plugin in content articles, you will find that these PHP commands and include_content_item tags do not get processed in the RSS feed generator that comes standard with Joomla 1.5 installation.

This article shows you how to have RSS feed process the DirectPHP commands and include_content_item tags so that users do not see all those PHP commands and tags 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 RSS feed process DirectPHP and Include Content Item plugin (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 (for Joomla 1.5.10 and above)

Very Important: this is for Joomla 1.5.10 and above. Thanks to Markstein who informed me about the change in Joomla code.

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, and add the five lines highlighted in yellow as shown below:
  4. 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;
    
    	if ((strpos($data->items[$i]->link, 'http://') === false) and 
    	(strpos($data->items[$i]->link, 'https://') === false)) {
    		$data->items[$i]->link = str_replace
    		(' ','%20',$url.$data->items[$i]->link);
    	}
    
    	$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";
    	}
    

  5. 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!

Solutions (for Joomla 1.5.9 and before)

Very Important: this is for Joomla 1.5.9 and before.

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   Average user ratings:    5.0   (from 1 user)
  1. ssnobben
    October 16, 2008 5:55am
    Thanks good extension to standars J 1.5

    Easy to use and very nice addon!

    Thanks!

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

 
< Prev   Next >

Blog - Forum - Privacy Policy - Contact Us
Copyright © 2006-2009. kksou.com. All Rights Reserved