Hello

Is it possible to enable CCK text field/s for php input?

I noticed this is only available with default body field, but I'm not being able to customize output of this.

The reason why I want to do that is that I have content type with 2 fields (title, description) and body (which supports php input).

I cannot customize the output of body - it will print all the fields (with content template module) instead of only body field so I was thinking of making a new CCK text field and enabling php for it (if thats possible) to have more control over it. How to do this?

Many thanks for help!

Comments

ghumpley’s picture

When creating a CCK text field, just ensure that you select "Filtered text (user selects input format)" under Text Processing. Then when you're creating a new node for that content type, you'll have the ability to select php as the input format.

l2u’s picture

How should I define content template for that kind of field?

Lets say I have created CCK text field which allows me to select the input format. How to set content template for this field so that it will know what to do?

Right now I have:

print $node->field_text[0]['value']

Which will only print the value. I want it to print the value and excute the php script (same as body field would do if I select php input).
If I select the html/filtered html I only want to print the data.

How should I implement this?

Many thanks for help!

l2u’s picture

Thanks a lot for helping..

nathan573’s picture

When making a CCK field PHP enabled with the "PHP code" input format, make sure that when you invoke the field in your template that you are referencing the "view" attribute, not "value" like you may with your other fields. The "value" version shows the raw PHP code, the "view" version is the parsed code.

$field_myfield[0]['view']

not

$field_myfield[0]['value']

Also, to get just the body content out of the node object, use:

$node->content['body']['#value']