Hello,
Im trying to echo a global drupal variable like $user in a php input format CCK field. So in the input field I would enter something like:
____
I am glad to see you back echo($user); . We have a bunch of new articles that you will love to read
____

My main goal is to access the other cck fields of the same node and using php I will output them in a particular way in the body cck field box. So I may use the title of the node and some custom fields and print them in the body cck field box. I am not looking to modify any template files but instead access the other cck fields within the same node by calling on them using an internal drupal variable like $node.

I tried using the $node = node_load(11) function and it worked ok. However I have to specify the node id. Is there something like $node = node_load(this); ?

Thanks

Comments

nevets’s picture

No, there is no $node in this context (when you first create a node it does not even exist). Which raises another point, at the time the field is built you only have access to any values from the last time the node was saved (or possibly default values if set).

marcvangend’s picture

I get the feeling that you're mixing things up a little. CCK is for the input of content, it's not for communicating with your users. If you want to display a message for a user, there are better ways to do it. What exactly are you trying to achieve?

beyond67’s picture

No Im not trying to communicate with users. Was just using that as an example. Would it be possible to repeat the title of the node within the body field?

My main goal was to use it with jQuery Media module. Currently I can add the following to the body field and it will change the width of the swf file:

jq_add('jquery_media', array('media width' => '600'));

I wanted to store the width in another CCK field and then call on it within the body field, i guess something like

jq_add('jquery_media', array('media width' => customCCKfiledvariable));

FLash files dont have set dimensions and I wanted to define them in a custom cck field. Some flash files have larger dimensions then others.

Maybe not the best way of handling it. But I was just curious on how to access drupal variable from within a body field.
Thanks

nevets’s picture

Your still being a bit vague but depending on the context you either have $node available or can make other fields available (ex views) and instead of trying to do things all in the body you might consider using theming.

marcvangend’s picture

What you could do is use Drupal's filters. Even though the node title may not be available at the moment of writing, you could enter something like [nodetitle] in the body text and let drupal replace that with the actual node title when rendering the node. Is that what you're after?

beyond67’s picture

Yea maybe. Where can I read more about these filters? Is there a filter that can reference custom cck fields? Like [nodecustomfield]

marcvangend’s picture

It's been a while since I've looked into this kind of functionality... I think the tokenize module (http://drupal.org/project/tokenize) comes close to what you're looking for, but the Drupal 6 version is work in progress: http://drupal.org/node/322366.