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! |
||
| < Prev | Next > |
|---|




