Htmlfix 1.04

Htmlfix has got a cousin!
If you need PHP code, or Htmlfix simply doesn't do what you need, please try MosSnippet.

New version 1.04!
Hopefully I finally got rid of the line break problem!

Htmlfix now with "safe mode" to ensure that the editor doesn't eat the tags.

Wysiwyg editors are nice as they allow you to enter and edit formatted text much as if you were working in a ordinary word processor. But sometimes you need full control over parts of the document you are editing, either because you want to finetune the result or because you need something the wysiwig editor simply can't do. Enter html and javascript!

The flip side of wysiwyg editors, however, is that they make it very difficult to enter HTML and javascript code manually. Most often they will simply convert the tags to so-called "HTML entities" which are special representations of the characters that look the same but are totally different. For example, the "<" character is converted to "&lt;". The end result is that it is not recognized as HTML code by the browser.

Normally you would have two choices now:

1. Edit the document in "HTML source" mode.
2. Disable the wysiwyg editor all together

The first option sometimes works, sometimes it doesn't. And sometimes it works shortly, but as soon as you edit the document again, you laboriously inserted code is stripped or altered. Often you will have to disable the editor to achieve want you need, but this is also quite tedious.

Let HTMLFIX mambot come into action!

Simply wrap you HTML or javascript sections in  {htmlfix} and {/htmlfix} tags directly in the wysiwig editor. That's all! Really! When the document is displayed, the mambot decodes the HTML entities introduced by the editor so the code will work again.

Here is an example:

HTMLFIX Mambot

Normally this manually inserted HTML code wouldn't show up as expected because the wysiwyg editor breaks the code.

Fortunately, the HTMLFIX mambot solves the problem once and for all!



And here is how it is written in the editor:

{htmlfix}
<div style="width: 300px; border: 1px solid gray; padding: 10px;">
<h1>HTMLFIX Mambot</h1>
<p>Normally this manually inserted HTML code wouldn't show up as expected because
the wysiwyg editor breaks the code.</p>
<p>Fortunately, the <strong>HTMLFIX mambot</strong> solves the problem once and for all!</p>
</div>
{/htmlfix}

Htmlfix in Static Content
In static content you cannot use the normal approach as the editor for some reason interprets the tags as html as soon as you press Apply or Save, ie. even before Htmlfix gets a chance to do its job. To circumvent this problem, Htmlfix as of version 1.03 allows you to specify a "safety character" to ensure the tags don't get eaten up be the editor. You specify the character by inserting it just before the closing bracket in the htmlfix tag, like:

{htmlfix } < b>You can now use space as "safety char"< /b>{/htmlfix}
{htmlfix:} <:b>You can now use colon  as "safety char"<:/b>{/htmlfix}


It is important that you always make the  {htmlfix} block as tight as possible. Only insert the tags around HTML/Javascript code. Wysiwyg formatting inside the tags will be removed!

{htmlfix}
This bold text will not show up as bold
<br>
<b>But this will!</b>
{/htmlfix}

As of Joomla 1.010 mambots are automatically executed in modules, making this fix unnecessary.

Unfortunately Mambo ignores mambots in PDF view. If you would like htmlfix to work in PDF files, you must apply the hack to the file pdf.php in the <mambo>/includes folder. The hacked file is contained in the zip package. You can also get it here: http://mamboforge.net/projects/mosif

The same applies to modules. If you use any mambot in for example a user module, they won't work. This means your neat html code wrapped in htmlfix tags does not show up!

If you need mambots to work in modules, you can make a hack to the file includes\frontend.html.php:


1. Take a backup of the file (just in case!)
1. Open the file in a text editor
2. Near the top, find the line: function module( &$module, &$params, $Itemid, $style=0 ) {
3. Just after the line add these 5 lines:

  global $_MAMBOTS;
  $_MAMBOTS->loadBotGroup( 'content' );
  $row->text=$module->content;
  $_MAMBOTS->trigger( 'onPrepareContent', array( &$row, &$params, 0 ), true );
  $module->content=$row->text;

Use the hacks at your own risk! Maybe some mambots don't like to get executed in modules. So far I haven't had any problems, though.


You can download htmlfix here or from Mamboforge:

Download htmlfix 1.04
http://mamboforge.net/projects/htmlfix/



Comments are temporarily disabled because they are not used as intended. They are just for - comments!, but people mostly use them for support questions. Please post questions in Joomla forum. Bug reports  and other feed back should go here.


Last Updated ( Wednesday, 15 November 2006 )