Hello,
Is there a way to implement this
http://www.sitepoint.com/article/highli ... e-code-php
into CMSMS? I'd love to see that implemented for my PHP related website.
Thanks for any input,
amygdela
PHP code color parser
Re: PHP code color parser
I would make a smarty block function to do this. It would live in the plugins dir and be called something like block.highlight.php. Then you should be able to do {highlight}{/highlight}.
The reference to the block function is here: http://smarty.php.net/manual/en/plugins ... ctions.php
The reference to the block function is here: http://smarty.php.net/manual/en/plugins ... ctions.php
Re: PHP code color parser
Wicked, that's a nice start! I'll have a look and see what I can build with it. Thanks
//EDIT
WOW!!!
Wicked!! I never knew writing plugins for smarty was this easy! it works like a charm.
Here it goes:
1. Download the package for the PHP highlighter here
2. Extract the package, and upload init.inc.php to your server in the same folder as your homepage
3. Create a new document, add this to it:
Save it as block.highlight.php in your /plugins folder.
Done! To use this block, use {highlight}{/highlight}
Perfect!
//EDIT
WOW!!!
Wicked!! I never knew writing plugins for smarty was this easy! it works like a charm.
Here it goes:
1. Download the package for the PHP highlighter here
2. Extract the package, and upload init.inc.php to your server in the same folder as your homepage
3. Create a new document, add this to it:
Code: Select all
<?php
include_once 'init.inc.php';
/*
* Smarty plugin
* -------------------------------------------------------------
* File: block.highlight.php
* Type: block
* Name: translate
* Purpose: translate a block of text
* -------------------------------------------------------------
*/
function smarty_block_highlight($params, $content, &$smarty)
{
if (isset($content)) {
highlight_string($content);
return $content;
}
}
?>
Done! To use this block, use {highlight}{/highlight}
Perfect!

Last edited by amygdela on Sat Mar 04, 2006 2:00 pm, edited 1 time in total.
Re: PHP code color parser
Nice. 12 minutes total. That's what I like to hear. 

Re: PHP code color parser
It would be nice if code highligting would be implemented in the CMS template/stylesheet editor.