0

I'm using a entity reference field on some content types. The field references taxonomy terms. Then I'm using a view to filter the available options. I'm passing the content type to that view using this token - [node:content-type:machine-name].

Essentially the field is used on different content types but the value is the same on each content type.

So the field is called product type. Content type "tin_labels" would have the value set to "Tin labels". A content type "Bags" would have the value set to bags for example.

For the contextual filter, I added the field "Taxonomy term: Name". I've added this PHP for providing the default argument in PHP code:

$content_type = $argument;
if ($content_type = 'tin_labels') {
  $term = 'Tin Labels';
  return $term;
}

elseif ($content_type = '3_5g_mylar_bag_design' || $content_type = '7g_mylar_bag_design') {
  $term = 'Mylar Bag Labels';
  return $term;
}

else {
  return;
}

I'm using no validation and currently get all values.

I'm pretty sure I'm not using the correct variable when setting $content_type. I tried to dpm($argument) but got nothing. Can't find any documentation that explains the structure of that value.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.