Greyhead.net

Home Joomla Add-ons ghSnippets plugin
ghSnippets plugin PDF Print E-mail
Written by GreyHead   
Thursday, 09 October 2008 10:23
 

The ghSnippets plugin for Joomla 1.5 allows you to insert snippets - text, htmp, php, script, etc - into any content page that will accept Joomla plugins.

Based on Martin Larsen's mosSnippets for Joomla 1.0 this version has been completely re-written for Joomal 1.5.

MosSnippet 1.01 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!

You can create up to 30 snippets using the fields to the right. You insert the snippets in content by referring to the number or an optional name. For example, {snippet 1} or {snippet my_snippet}. 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.

Text or html: Just paste the text/code into the snippet field. It will be inserted exactly as you entered it.

<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 not work. Remember your semicolons!

<?php
  echo "MosSnippet rules!"; ?>
<?='no echo needed here'?>

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

<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"; ?>

This is a re-write for Joomla 1.5 based on mosSnippets for Joomla 1.0 by Martin Larsen

If you suggestions for improvements, or find any bugs please post a comment below.

Last Updated on Thursday, 23 October 2008 13:09