1
votes

I am wanting to display a view differently depending on CCK field values that exist on the current node being viewed. I have found many solutions relating to user id and node reference fields, but they don't seem to work in this use case..

I have a view that contains 3 attachment displays, the first returns a single randomly sorted result; the second returns a slideshow of results; and the third, a list of all results.

To select which of these attachment displays to show, the content has two fields - field_content_ad_slideshow and field_content_ad_showall. Both of these are set as yes|Yes and no|No. In other words, it is a checkbox, where selected is 'yes' and unselected is 'no'.

I want attachment 1 to display if both values = no. attachment 2 to display if field_content_ad_slideshow = yes and attachment 3 to display if field_content_ad_slideshow = no and field_content_ad_showall = yes (therefore if both values are yes, attachment 2 will display)

Due to reasons I wont go into, I cannot use the views filters to limit each display and so am trying to do it in the argument. I have tried setting the Default argument type to 'Node ID from URL' and the validate code to -

if (arg(0) == 'node' && is_numeric(arg(1))) {$node = node_load(arg(1));}
if ($node->field_content_ad_slideshow[0]['value'] == 'no' && $node->field_content_ad_showall[0]['value'] == 'no') {return  TRUE;}
else {return  FALSE;}

This doesn't work.

I have also tried changing the validator code to basic validation and the Default argument type to

if (arg(0) == 'node' && is_numeric(arg(1))) {
$node=node_load(arg(1));
$slideshow = $node->field_content_ad_slideshow[0]['value'];
$showall = $node->field_content_ad_showall[0]['value'];
$display = null;

if($slideshow=='no' && $showall=='no') {
$display == 'true';
}

if($display) {
$args[0] = (arg(1));
} else {
$args[0] == '';
}
return $args;

Neither of these work. Any help much appreciated!!

Thanks Rob

1

1 Answers

0
votes

You have it as $display == 'true' So the $display var always validates as false.

Also I thought args were returned as strings and multiple args were managed using the '+' signs in views options. But this was in drupal 6.

Good Luck!