News Feed E-mail

Get How-To's right in your inbox. Subscribe to the HowToJoomla! news feed e-mail. Just enter your email address here:

Delivered by FeedBurner

Login






Lost Password?
No account yet? Register

Affiliates

Azrul's JomComment
JoomlaShack
iJoomla
The Joomla! Store
Member of W3C Sites dot com
How to use the GeSHi plugin/mambot PDF Print E-mail
Written by Cory   
Tuesday, 22 July 2008

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.

Trackback(0)
Comments (6)add comment
Jason Boyette: ... http://www.jkboyette.com
Thanks for this. Do you know of any place where you can get all the syntax requirements for GeSHi in 1.5?
1

report abuse
vote down
vote up
July 24, 2008
Votes: +0
Hi Jason...I'm not sure if I understand the question.
2

report abuse
vote down
vote up
July 24, 2008
Votes: +0
Jason Boyette: ... http://www.jkboyette.com
You say for 1.0,
You can change 'lang="html"' to other languages like 'lang="php"' so that GeSHi highlights it according to the language you are using.


In 1.5, if you want to display PHP code, do you change it to ? How about CSS? I'm looking for a resource for the syntax inside the tag.

Maybe I'll just use the old trial-and-error method.
3

report abuse
vote down
vote up
July 24, 2008
Votes: +0
Jason Boyette: ... http://www.jkboyette.com
Shoot, the comment system removed my tags!
4

report abuse
vote down
vote up
July 24, 2008
Votes: +0
in 1.5, instead of

lang="php"


you use

xml:php


you could trade out php for html, css, etc. I'm not sure of all the languages it supports...
5

report abuse
vote down
vote up
July 24, 2008
Votes: +0
Jason Boyette: ... http://www.jkboyette.com
Thanks! That's what I was looking for. If I find any more information, I'll write back.
6

report abuse
vote down
vote up
July 24, 2008
Votes: +0

Write comment
quote
bold
italicize
underline
strike
url
image
quote
quote
smile
wink
laugh
grin
angry
sad
shocked
cool
tongue
kiss
cry
smaller | bigger

busy
 
Tag it:
Delicious
Digg
Technorati
< Prev   Next >
Advertisement

About HowToJoomla

HowToJoomla was started in September 2006 by me, Cory Webb, a long-time Mambo/Joomla user with a desire to give back to the community that has given so much to him.

HowToJoomla is not the best, most comprehensive Joomla tips site out there. That's not the goal. The goal is to share some of the knowledge and experience that I have gained through years of using the world's best content managment system. I hope that you will find this site useful and visit often. As I come across new tips and ideas, I will post them here for all to see.

I hope you enjoy using HowToJoomla and find it very useful.

Please take some time to read the Disclaimer.

Thanks for visiting!

About Me

I am a 28-year-old husband and father of a beautiful baby girl named Lucy. I have a degree in Electrical Engineering from the University of Texas at Austin, an MBA from Baylor University, and over 4 years experience working with the Mambo/Joomla CMS.

On February 1, 2008, I started a web design, development, and consulting company specializing in designing and developing custom Joomla-powered websites. The new company is aptly named Cory Webb Media, LLC. The double meaning is purely unintentional, but with a last name like "Webb" it is difficult to escape the obvious puns. If you are looking for professional assistance with your website, please feel free to contact me to discuss your project.

I also run HowToJoomla, CoryWebb.com (my personal website/blog), and JoomlaForm.com (a site dedicated to promoting good design in the Joomla! community). In my spare time (if there is such a thing), I volunteer with the youth ministry at my church.

Copyright © 2006 - Cory Webb Media, LLC - All rights reserved.
Powered by Joomla!