Online Joomla Training

Joomla! How-To's: Mambots/Plugins

How to use the GeSHi plugin/mambot

July 22, 2008 | by Cory

Joomla! comes with a plugin/mambot called GeSHi that comes in quite handy if you have a site like HowToJoomla.net in which you share code snippets with your readers. I recently tried to use GeSHi on a Joomla! 1.5 site, and I found that it works differently in Joomla! 1.5 than it does in Joomla! 1.0. Read on to see how to use it in both.

What is GeSHi?

GeSHi stands for "Generic Syntax Highlighter", and it is used to highlight code snippets in different web languages like PHP, HTML, and CSS. It also converts tags in those languages so that they will not render like regular tags.

For example, if you want to share some HTML code, you have to use something like GeSHi, or the browser will treat your HTML code like regular HTML code.

The following code is done without GeSHi:

Without GeSHi

The following code is done with GeSHi:

 
<p><strong>With GeSHi</strong></p>
 

Not that in the code with GeSHi, you can see the HTML tags, and in the code without GeSHi, you cannot see the HTML tags. The words "Without GeSHi" are rendered like regular HTML

How to use GeSHi in Joomla! 1.0

To use GeSHi in Joomla! 1.0, you use the following HTML code:

 
<pre lang="html">
 <!-- your HTML code here -->
</pre>
 

You can change 'lang="html"' to other languages like 'lang="php"' so that GeSHi highlights it according to the language you are using.

How to use GeSHi in Joomla! 1.5

GeSHi has a very slight difference in Joomla! 1.5. Here is an example:

 
<pre xml:html>
 <!-- your HTML code here -->
</pre>
 

Note that instead of 'lang="html"', you use 'xml:html'. That is the only difference. I'm not sure why they did it that way, but they did so if yo plan on using GeSHi for Joomla! 1.5, you need to be aware of this.

Questions/Comments

As always, questions and comments are welcome.

About the Author

Cory WebbIn the years since Joomla! was founded, Cory has built dozens of websites with Joomla! and helped thousands of people find answers to questions about Joomla! through HowToJoomla.net. Cory has also written a book about Joomla titled Beginning Joomla! Web Site Development published by Wrox in April, 2009. In February of 2008, Cory founded Cory Webb Media, LLC, where he provides consulting and web development services for companies of all sizes. You can follow Cory on Twitter @corywebb, or become a fan of Cory Webb Media on Facebook. Cory is also the founder of Themeables, a template club for Joomla!, and developer of /motif, the framework that powers Themeables.

Read More

blog comments powered by Disqus
Online Joomla Training