Hi all,

I'm trying to get a CCK text field to process php. This seems to work and not work for me. When I view the resulting node it works fine but when i try and print out the field in another context, the php does not get processed.

The code I use for display the content of the field is the following (part of it):

//Do middle box
if($anodeTwo->field_auglysing_2)
{
$middle_box_obj = $anodeTwo->field_auglysing_2;
$middle_box = $middle_box_obj['0'];
$middle = $middle_box['value'];

if($middle)
{
print '

' . $middle.'

';
}
}

This has always worked with text so far but for some reason if I use php code in that field it never gets processed :(

You can see the source here: http://www.hi.is/is/auglysingar/auglysingar_fyrir_felagsvisindasvid

and there is also a screenshot.

Any ideas? I gotta be doing something stupid!

best regards, Logi

CommentFileSizeAuthor
screenshotdrupal.JPG76.31 KBLogi-1

Comments

Logi-1’s picture

Sorry had to remove the content on the page and cannot link externally to my dev server, if anybody has any ideas, please share :)

markus_petrux’s picture

Status: Active » Fixed

If you do it that way, then you're just rendering the field value as-is, which is your PHP snippet. Instead, try using content_format() or something similar. Not sure if there's documentation for this related to CCK for D5, anyway see content.module and search for content_format() to read the inline docs.

Logi-1’s picture

Right!

That worked, thanks for that :)

I changed this to: $middle = content_format('field_auglysing_2', $anodeTwo->field_auglysing_2[0], 'default', $node);

best regards, Logi

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.