SORTED
http://drupal.org/node/467190#comment-2068324
Hi friends,
I've spent all day to find but can't find :(
How can I display CCK Field value with php in views_customfield? I tried the ones below, but no result
$node->field_homepage_linking[0]["view"]
$node->field_homepage_linking[0]["value"]
value_get('field_homepage_linking')
Appreciate helps!!
$node->field_homepage_linking[0]["view"]
this works in tpl.php files, not not working in View Module panel as below (screenshot)
alt text http://img.skitch.com/20100616-dy2pxkdichni7nu1h747tptfa8.jpg
<?php
if ($node->field_homepage_linking[0]["view"] == 1) { ?>
<a href="<?p开发者_C百科hp print drupal_get_path_alias("node/" .$data->nid) ; ?>" title="<?php print $data->node_title; ?>">
<?php } ?>
<?php print $data->node_title; ?>
<?php if ($node->field_homepage_linking[0]["view"] == 1) { ?>
</a>
<?php } ?>
Looks like a clerical error.
$node->field_homepage_linking["0"]["value"]
Should be:
$node->field_homepage_linking[0]["value"]
Although, if its a CCK field, why not just add it as a Field? All CCK fields are under the Content category of the Fields. Also, to do this, you need the $node object loaded and ready to use by Views, which may also be why you aren't seeing anything.
Looks like you want to have a conditional display. I am not sure how to do this in Customfield, but I have done this many times with a .tpl field for particular fields. You can add theme tpl files to Views and have PHP code inside it, and also dump out the $row and $data object of views to see what fields/values you have to work with.
SORTED http://drupal.org/node/467190#comment-2068324
This works for me: The PHP code in customfield for loading cck field
$node = node_load($data->nid, NULL, TRUE);
echo $node->field_name_of_field[0]["value"];
精彩评论