GeSHi with CCK and Contemplate not working

BrianH - November 12, 2008 - 08:03
Project:GeSHi Filter for syntax highlighting
Version:6.x-1.1
Component:Filtering
Category:support request
Priority:normal
Assigned:Unassigned
Status:active
Description

GeSHi is working fine for standard nodes (story, page etc) but if I use a Contemplate to style my custom nodes (and wrap them in a GeSHi code tags), nothing happens.

I guess it is because the node is being processed by GeSHi before Contemplate has had a chance to wrap it in a GeSHi code tag?

Does anyone know how to get this working?

#1

BrianH - November 13, 2008 - 01:15

I'd still like to be able to do the above, but for the time being I am doing the code highlighting by calling geshi from directly within the contemplate (i.e. not relying on the drupal geshifilter module).

#2

soxofaan - November 13, 2008 - 09:05

GeSHi is working fine for standard nodes (story, page etc) but if I use a Contemplate to style my custom nodes (and wrap them in a GeSHi code tags), nothing happens.

What does "nothing happens" mean? What do you expect? What do you get?
I'm not very familiar with Contemplate, so please elaborate a bit on that.

#3

BrianH - November 15, 2008 - 00:12

By "nothing happens" I mean exactly that. No geshi syntax highlighting. No php errors. Just the raw, unadorned node content output.

Contemplate allows creators of CCK (and in fact any) node types to have unlimited control over how their nodes are displayed. You decide what is displayed and structure the output using PHP. Typically Contemplate exposes node attributes and fields like so:

<?php
$node
->title;
$node->field_name[$index]['value'];
?>

In my contemplate, I take all my separate CCK fields (each of which represents an API class, method or variable), format them into an API interface and wrap them in a code tag with language attribute (to trigger geshi filtering), however the geshi filter seems not to work with this. I assume this is because drupal filters must be run before contemplate gets hold of the output, and then by me using the exposed variables above to access the raw content I am essentially bypassing any filtered content. If, on the other hand someone were to put a code snippet into one CCK field and wrap it with code tags and language attribute, I'm sure that would work as expected.

No matter, as using geshi.php directly in this case seems to work fine. It is just impossible to control via the geshifilter module administrative interface. I must do it in code within the contemplate itself e.g.

<?php
// Syntax highlighting with GeSHi direct (not via Drupal geshifilter module)
include_once "sites/all/modules/geshifilter/geshi/geshi.php";
$geshi = new GeSHi($src, "java");
echo
$geshi->parse_code();
?>

 
 

Drupal is a registered trademark of Dries Buytaert.