Kreacom.dk
Snippet Plugin Print

MosSnippet is a plugin (mambot) to insert text, html or php code in content. Now you don't have to worry about the wysiwig editor sabotaging your precious code!

New version 1.01

I found a problem with the way Joomla stores parameters. Whenever you insert a linebreak in a text field (like a snippet), Joomla converts the linebreaks to <br /> tags. These tags can easily ruin your javascript or php code. It's really stupid, but it happens.  This version reverses the process by converting the tags back to normal linebreaks again.

This is fine, but if you in fact do need a <br /> you don't want them converted to linebreaks. Instead you just enter them in uppercase <BR /> or without the space <br/> or without the end slash <br>. These will not get converted to linebreaks.

Also new in  1.01 is that you can now store 30 snippets instead of 15.

 

You can create up to 30 snippets using the fields in the mambot editor. You insert the snippets in content by referring to the number or an optional name. For example, {snippet 1} or {snippet paypal}. When processed, the tags will be replaced with the snippet in question. Text and html code will be inserted unaltered, while php code will be interpreted. 

 

Examples

Text or html
Just paste the text/code into the snippet field. It will be inserted exactly like entered.

Example:
<a href="javascript:alert('MosSnippet rules!')">Click here<a/>

PHP
You must enclose the code with <?php and ?> tags. Just like ordinary PHP code.
You can use the <?= syntax as a shorthand for <?php echo ....

NOTE: It is VERY important that the php syntax is correct, or it will nok work. Remember semicolons!

Examples:
<?php
  echo "MosSnippet rules!";
?>

<?='no echo needed here'?>

Mix
You can mix everything if you just remember the appropiate opening and closing tags. You can have as many blocks of html and php as you like.

Example:
<h1>MosSnippet</h1>
MosSnippet is a great plugin for inserting html and php in content!<br/>
<?php
global $my;
if($my->id)
  echo "Hello $my->name";
else
  echo "Hello guest";
?>

Linking external files
This is done using straight php: <?php include "myfile.php"; ?>

 

Download MosSnippet 

Last Updated ( Tuesday, 05 June 2007 )