So, I have setup a content type called 'Client Page' and within it I have setup 2 CCK fields:

Client Content which is multiple text fields (this is the only field the client can edit)

and

Developer content which is a text area with the PHP input filter enabled. What I am trying to do is develop pages using HTML and then using PHP to print the values inputted by my clients i.e.


<div>

<h2>Address:</h2>

<?php print $node->content->['field_clientcontent'][0]['value']; ?>

</div>

I tried this on the Body field and it works (UPDATE: I am unable to get it working for the Body field) but for some reason when I try to php print using my custom CCK field nothing shows up..?

Any Ideas would be greatly appreciated.

Thanks,

rhughes

Comments

peterjlord’s picture

Install the devel module http://drupal.org/project/devel then you'll get some debugging tools.

You can then do a

<?php
  dsm($node);
?>

which will give you access to a JavaScript variable browser then you get a better idea of what you've got access to

rhughes’s picture

Hmm,

I installed the module and went into the dev tab for the page and saw this listed:

field_clientcontent (Array, 2 elements)

*
0 (Array, 1 element)
o
value (String, 13 characters ) testing 1 2 3
*
1 (Array, 1 element)
o
value (String, 15 characters ) testing 1 2 3 4

So that field is apparently available...

medenfield’s picture

I believe there is an error here.

<?php print $node->content->['field_clientcontent'][0]['value']; ?>

Should be

<?php print $node->field_clientcontent[0]['value']; ?>

Also, it's dirty, but you can always do a

<?php print_r($node);?>

in your node template and look at the source code to see some structured goodness for this content type

rhughes’s picture

So this is really weird, when I simply enter


<?php print_r($node);?>

It returns nothing, its like the $node variable is not recognized.

..because I can execute


<?php print "Foo Bar"; ?>

and it will show up just fine, so the PHP filter must be working correctly...

cog.rusty’s picture

In which template is that. If you are in page.tpl.php, are you looking at a full node page? If you are looking at a teaser list of many posts, of course there is no one $node.

nevets’s picture

It sounds like you want to theme the node, in Drupal we use templates for that. Your PHP field does not have a default $node.