Hi guys, the following article is a copy&paste from the original one on my blog, if some style is messed up... have patience! ;-)


GeSHI is a cool plugin which enables you to "embed" HTML ( or whatever ) code into your view.

usage of GeSHI can be:


  • print the code of your programming language tutorials
  • give your user code to embed some of your stuff
  • whatsoever

Using GeSHI inside the content editor is simple, but what if we need to automatically embed code in a custom extension?

For example, when you create a "Our banners" module/component/... your customer will ask you to display the embed code for the visitors, and you can't tell him that he has to manually write the HTML code to embed the banners.

So, inside your code you only need to place this snippet:

// import GeSHI stuff

jimport('geshi.geshi');
jimport('domit.xml_saxy_shared');

// define the regex: this is the standard GeSHI regex, don't edit it

$regex = "#<pre xml:s*(.*?)>(.*?)</pre>#s";

// call GeSHI to edit the output of $myText

$myText = preg_replace_callback( $regex, 'plgContentGeshi_replacer', $myText );


That's it, GeSHI will automatically output the content as desired.

Views: 6

Comment by Amy Stephen on April 15, 2010 at 7:25am
Nice! Thanks very much!

Comment

You need to be a member of All Together, As A Whole to add comments!

Join All Together, As A Whole

Badge

Loading…

© 2012   Created by Amy Stephen.

Badges  |  Report an Issue  |  Terms of Service