Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I higlight PHP code in the Drupal 6 editor?

I have been looking for a good editor with syntax highlighting for php code to be used in the drupal 6 node body.

I would like to clear one thing first, I DO NOT need a syntax highligter for a code "posted" or "displayed" in the node. But I need to write php codes for some pages and writing them like a text without any highlighting, is pretty annoying.

As you can see below, I would like the php syntax <?php echo "Hello world"; ?> to be highlighted.

enter image description here

I tried many combinations and not found anything that I really desire. below are some things that I tried...

I tried TinyMCE with codemagic, codemirror, editarea. But nothing really works as they should. adding to the above, trying to write and preserve code in any wysiwyg editor is a real pain in the a**.

Then I tried colorer module but am facing many problems and not even a single bug report and issue of this module is fixed.

So isn't there a way to write php code as code and not as text inside the drupal nodes..?? Or is it that nobody bothered about it because anyone hardly writes php code inside nodes..? I hope am not the only one and some solution to it does exist.

like image 841
akshaynhegde Avatar asked Dec 30 '25 12:12

akshaynhegde


1 Answers

The ACE editor works really well as a code editor for <textarea>s, and it has a Drupal module. ACE is well maintained, so I'd check them out as an alternative to colorer, TinyMCE, et al.

Edit: However, it's only for Drupal 7, which won't help...

like image 161
Andrew Avatar answered Jan 02 '26 03:01

Andrew



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!