Insert a plugin (or a module) anywhere

You might need to use a plugin's output in a component, or to insert a module in a page outputted by an arbitrary component. I mean ANY plugin which has it's own output in ANY Joomla component you like.

I know, there are couple of ready-made solutions, but all of these are specific to a given component(s) and some components have their own plugins to do that.

The solution is simple - but you need to make your hands dirty with some PHP code.

First of all, locate the code in your component where you want to insert your plugin's output. (with "loadposition" plugin you can insert a module position too, so no special tricks for inserting the modules). Remember, if the component is MVC compatible, you can (and you should) use the template overrides, instead to hack into the components core code!

Insert the following code in the desired location:

<?php echo JHTML::_('content.prepare', '{someplugincode}');?>

For example, if you want to insert the modules published in the "listings" module position, you can use this code:

<?php echo JHTML::_('content.prepare', '{ loadposition listings }');?>

Save it, and enjoy! (Remove the extra spaces around curly brackets!)

Here are a working example:

With this hack you can insert a plugin or a module anywhere you want on your website. This hack can be used on any virtual host that has PHP.