Page 1 of 1

Support for CODE tag in CMSMS?

Posted: Thu Feb 26, 2009 7:13 pm
by moncho007
Hello, everyone!

Nice to join the community!

This is my first post here, so don't shout too much if it is in the wrong forum.  :)

Anyway.. I'm using CMSMS for a week now and I'm very happy with it :)

Most of my pages are displaying different types of source code - PHP, C/C++, MySQL, Shell code, etc..

What I miss is a way to highlight such a code, because selecting the text and then choosing a background color for it is not a very pleasant task.

So, I was wondering is there a way to use such a CODE tag, because I was looking over and over and found nothing...

Could you, please point me to the right direction on how to accomplish this?

Greetings!

Re: Support for CODE tag in CMSMS?

Posted: Fri Feb 27, 2009 7:46 am
by moncho007
Ok, guys I think I've found a solution - Geshi

But... The information in the Wiki doesn't work for me..

Can you please, help me to install Geshi with CMSMS?

Thanks!

Re: Support for CODE tag in CMSMS?

Posted: Fri Feb 27, 2009 5:10 pm
by streever
Hi there moncho,

why not just use CSS?
simply create a css style like so:
p.code {padding:10px;background-color:#999;border:1px solid #000;}
p.code:before {content="Code:"}
This will create a bordered, colored box around your paragraph. In CSS2 browsers, it will also add the words, "Code:" before each code block.

You just click into a paragraph of code, & select "code" from the drop-down style box in tinyMCE in the editor. Easy!

OF course, :after, doesn't work in IE6/IE7 because the programmers are lazy & don't care about supporting CSS spec 2 :). But who cares, most of your visitors to a programming site are going to be using real browsers, & the ones who aren't, just miss the word "Code". Hardly a deal breaker.

Alternatively, you could write your own CMSMS tag which allows you to enclose stuff in {code}[/code}: just make sure to build into it {literal}{/literal} & p.code or whatever you call it.

Re: Support for CODE tag in CMSMS?

Posted: Fri Feb 27, 2009 6:36 pm
by moncho007
Hi,

Thanks for your reply!

The CSS option is not bad, but I'd like to able to highlight different languages - just look in the geshi homepage how much languages they support - it will be a very difficult task to create so much CSS styles for each language.

Anyway, I'll try to install geshi once again this evening - hopefully successful this time :)

Thanks again!

Re: Support for CODE tag in CMSMS?

Posted: Fri Feb 27, 2009 6:45 pm
by calguy1000
Here's a geshi plugin:

Steps:
1) Install geshi in your lib directory
2) Install this plugin as block.geshi.php in your plugins directory
3) Use it in a global content block like this:
     {geshi lang='smarty' linenumbers=1}{literal}
       {* a smarty template *}
     {/literal}{/geshi}
4) call your global content block:  (don't use a wysiwyg)
      {global_content name='geshi_sample_code'}

Parameters:
   root_path = specify a different location for geshi
   lang = specify the language of the code you're displaying
   linenumbers = display line numbers
   class = specify the class of the containing block
   strict = enable geshi strict mode

Re: Support for CODE tag in CMSMS?

Posted: Fri Feb 27, 2009 6:46 pm
by streever
I was going to say, I bet it's very easy to do as a plugin, & i'm sure calguy or someone else will post one soon ;-) Nice work calguy.

Re: Support for CODE tag in CMSMS?

Posted: Sat Feb 28, 2009 12:14 pm
by moncho007
Thanks very much to everyone!

Now I can start highlighting with GeSHi ! :D

Re: Support for CODE tag in CMSMS?

Posted: Sun Mar 01, 2009 8:26 am
by moncho007
calguy1000 wrote: 3) Use it in a global content block like this:
     {geshi lang='smarty' linenumbers=1}{literal}
       {* a smarty template *}
     {/literal}{/geshi}
4) call your global content block:  (don't use a wysiwyg)
      {global_content name='geshi_sample_code'}
But doesn't that mean that the Global Content Block is a constant?

So when I need to highlight a different code with GeSHi each time I'll have to create a new GCB?