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)?. ExplanationsIn 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!
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";
}
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!
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";
}
That's it! Now try your RSS feed. Your PHP commands should now be processed in the RSS feed too! NoteI 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) Note: You have to be a registered member to leave a comment. Free registration here. |
||
| < Prev | Next > |
|---|
Joomla 1.0 Articles
- How to create a module with DirectPHP plugin?
- How to include modules in Content item?
- How to include modules in Section/Content Description
- How to include PHP commands in Section/Content Description
- How to make plugins process Section/Category descriptions
- Include Code Listing plugin - More Tips and Techniques
- How to have DirectPHP plugin process RSS feed?
- How to have the plugins processed when genrating PDF documents of content items?
- How to have DirectPHP commands processed in Joomla search?
Joomla 1.5 Articles
- How to create a module with DirectPHP plugin?
- How to include modules in Content item?
- How to include modules in Section/Content Description
- How to include PHP commands in Section/Content Description
- How to make plugins process Section/Category descriptions
- Include Code Listing plugin - More Tips and Techniques
- How to have DirectPHP plugin process RSS feed?
- How to have the plugins processed when genrating PDF documents of content items?
- How to have DirectPHP commands processed in Joomla search?
Joomla Plugins
Joomla Components
Joomla Gadgets
- Google Image Search
- Google News Search
- Wikipedia Search
- Google Book Search
- Google Video Search
- Google Currency Converter - AJAX version
- Yahoo Currency Converter - AJAX version
- Yahoo Stock Quote (AJAX module version)
- Yahoo Stock Quote (AJAX component/ module version)
- googleSearch_cse component
- googleSearch_cse module
- googleMaps plugin







5.0 (from 1 user)
October 16, 2008 5:55am
Easy to use and very nice addon!
Thanks!