Posted By

harikaram on 10/15/10


document json joomla raw

Versions (?)

Run content plugins on JDocument type RAW (ie temp. replace JDocument with a different type)

 / Published in: PHP

Say you want to run content plugins on JDocumentRAW content (like in a component that returns JSON data). Some methods in JDocumentHTML like "addCustomTag" will cause the app to fail on JDocumentRAW doc types which don't have this method. Thus you need to temporarily replace it to trick the content plugins...

  1. $document =& JFactory::getDocument();
  2. $oldDoc = clone( $document );
  3. $document = JDocument::getInstance('html');
  5. JPluginHelper::importPlugin('content');
  6. $article = new JObject();
  7. $article->text = $lesson->rendered;
  8. $dum = array();
  9. $dispatcher->trigger( 'onPrepareContent', array( &$article, &$dum, 0 ) );
  10. $lesson->rendered = $article->text;
  12. $document = $oldDoc;

Report this snippet  

You need to login to post a comment.