Get component content in joomla

2019-09-19 17:17发布

问题:

I'm making a system plugin and I need a way to put html before any components and after header,menu ecc. in other words I need to put html before this in template:

<jdoc:include type="component" />

Thank you

回答1:

I found what I need:

  // get the document object.
  $doc = JFactory::getDocument();

  // get the buffer
  $buffer = $doc->getBuffer('component');

  // your string to insert
  $insert_string = "<p>I've been inserted</p>";

  // insert the string
  $buffer = $insert_string . $buffer;

  // reset the buffer
  $doc->setBuffer($buffer, 'component');


回答2:

If you want to modify the contents of the webpage then you should be making a "content" plugin as opposed to a "system" plugin.

A good place to start is by looking at the emailcloak plugin that ships with Joomla! 1.6+ (note that the plugin interface is quite different for Joomla! 1.5 versus the current 1.6/7/2.5 era plugins). If you're working with 1.5 then have a look the example plugin that ships with it.

This doc covers "Creating a content plugin"