views:

449

answers:

2

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

<?php 
 if ($node->field_homepage_linking[0]["view"] == 1) { ?>
    <a href="<?php 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 } ?>
A: 

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.

Kevin
yes yes I tried $node->field_homepage_linking[0]["value"], but still not working. I have created this block with block, then I need to add such a silly control, that's why I'm trying to implement this to my current view. Themer gives views-view.tpl.php name as candidate. it looks so common name, I created many blocks with view, and i dont wanna mess :/ offf
artmania
It can override all views or very specific views, its up to you. Views gives you the choice of specificity when it comes to TPL overrides.
Kevin
A: 

SORTED http://drupal.org/node/467190#comment-2068324

artmania