Hello there,

I added a customfield to a view and used

<?php
print var_export($data, TRUE);
?>

to print out the available $data

then is put

<?php
print count ($data->node_data_field_members_field_members_uid);
?>

in the customfield.

If you look at the attachment you will see that some of counts are incorrect.

Anyone any ideas what's going on?

CommentFileSizeAuthor
customerror.png3.26 KBludo1960

Comments

ludo1960’s picture

Seems the customfield is counting Null as a value:

stdClass::__set_state(array( 'nid' => '1', 'node_title' => 'A4E Scotland Ltd', 'node_type' => 'guide_organisation', 'node_vid' => '173', 'node_data_field_members_field_members_uid' => array ( 0 => array ( 'uid' => NULL, ), ), )) 

the output from

<?php
print var_export($data, TRUE);
?>

Tried:

<?php
if (!is_null($data->node_data_field_members_field_members_uid))
print count($data->node_data_field_members_field_members_uid);
?>

Should I go back to php school? :)

ludo1960’s picture

Solved,

Getting rid of Null aint so easy, here's how to do it:

<?php
$aResult = array();
foreach ($data->node_data_field_members_field_members_uid AS $item)
{
    if (!is_null($item['uid']))
    {
        $aResult[] = $item;
    }
}  
print count($aResult);
?>