Joomla 1.5: Filter mambots and plugins’ codes in PDF and print view

Homepage > Home > Coding > Joomla 1.5: Filter mambots and plugins’ codes in PDF and print view

Tue 05/19/2009

in Coding, PHP

One of the coolest feature in Joomla content editor is the ability to insert specific modules’ position whereaver you want. This is particularly usefull to loadĀ  inline banners or to add quick polls to an article/page just by inserting {loadposition mypostion} in your editor textarea.

In Joomla 1.5.x everything works fine when viewing the page as HTML, but in PDF and print friendly format view these shortcodes aren’t converted nor removed. Moreover displaying these contents could be unnecessary or unwanted.

This problem arise because in pdf and print view files in Joomla com_content component not all content plugins (those addons called mambots) are loaded. In PDF view file components/com_content/views/article/view.pdf.php there’s just one plugin (called image) loaded before the content is outputted (lines 68 -69):

JPluginHelper::importPlugin('content', 'image');
$dispatcher->trigger('onPrepareContent', array (& $article, & $params, 0));

The (dirty) solution

From a quick glance in the plugins/content folder i’ve noticed that there’s no any image.php pluginĀ  file in a clean Joomla 1.5.10 installation. So i’ve decided to use this hole and create a custom plugin to clean my content without messing up the core com_content code.

After installing the plugin and activating it you are given (at the moment) two options:

  • a radio to clean loadposition code (defaults to Yes)
  • a textarea for typing custom regular expressions (one per line).

In this last field remember to omit backslashes (/) instead write curly brackets, for example {code\s*[a-zA-Z]}

Here is the package for download: plg_image (clean plugins code) (1.79 kB)

As always feedbacks and suggestions are welcome.

No Related Posts

Tags: , , ,

4 Responses to this post:

Leave a Reply ()

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

* required.