Support for CODE tag in CMSMS?

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
moncho007
New Member
New Member
Posts: 8
Joined: Thu Feb 26, 2009 7:03 pm

Support for CODE tag in CMSMS?

Post 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!
moncho007
New Member
New Member
Posts: 8
Joined: Thu Feb 26, 2009 7:03 pm

Re: Support for CODE tag in CMSMS?

Post 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!
streever

Re: Support for CODE tag in CMSMS?

Post 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.
moncho007
New Member
New Member
Posts: 8
Joined: Thu Feb 26, 2009 7:03 pm

Re: Support for CODE tag in CMSMS?

Post 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!
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: Support for CODE tag in CMSMS?

Post 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
Attachments

[The extension txt has been deactivated and can no longer be displayed.]

Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
streever

Re: Support for CODE tag in CMSMS?

Post 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.
moncho007
New Member
New Member
Posts: 8
Joined: Thu Feb 26, 2009 7:03 pm

Re: Support for CODE tag in CMSMS?

Post by moncho007 »

Thanks very much to everyone!

Now I can start highlighting with GeSHi ! :D
moncho007
New Member
New Member
Posts: 8
Joined: Thu Feb 26, 2009 7:03 pm

Re: Support for CODE tag in CMSMS?

Post 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?
Post Reply

Return to “CMSMS Core”