27July

Execute Joomla content plugins on string

In Joomla 1.7 (and I assume Joomla 1.6) you can very easily execute content plugins on a string.

$text = JHTML::_('content.prepare', $text );

This is much simpler than the previous method in Joomla 1.5:

$Item = JTable::getInstance('content');
$dispatcher = JDispatcher::getInstance();
$params = new JParameter('');
JPluginHelper::importPlugin('content');
$Item->parameters = new JParameter('');
$Item->id = "";
$Item->state = "";
$Item->catid = "";
$Item->sectionid "";
$Item->title "";
$Item->text = "Your text with {content plugin code}";

// Apply content plugins to custom text
$results = $dispatcher->trigger('onPrepareContent', array (&$Item, &$params, 0));

Posted in Tutorials, Joomla

Comments (0)

Leave a comment

You are commenting as guest.

Cancel Submitting comment...

About Dave Horsfall

Dave Horsfall is a British software developer and founder of the hwdMediaShare project. More...

Recent Comments

  • Ppl like you get all the brains. I just get to say thanks for he awnesr.

    Rosa, 06. September, 2011 |

  • Ppl like you get all the brains. I just get to say thanks for he awnesr.

    Rosa, 06. September, 2011 |

  • No, the file should be called "project.properties", and it should be located in the same directory as the file called "project.xml". I'm...

    Dave Horsfall, 29. August, 2011 |

  • There is no file called "project.properties". There is a file "project.xml" is this the one? It is not "simple text" though...

    OppfinnarJocke, 29. August, 2011 |