0

Currently I am using the path url to pass in arguments:

path: /%/%/%

On the 3rd argument I am loading a Taxonomy term. I also have a field loaded called: field: device type

What do I have to put in my contextual filter validation PHP code? I did a dsm($view), but my device type shows recursion. I'm not sure how to reference the field properly to create a conditional to compare it to the contextual argument.

enter image description here

  • you're asking about how to get or use the third argument from the URL or all of them? – Jack-PL Jul 2 '13 at 23:55
0

Below is a code sample of my contextual filter validation code for drupal 7 views 3 validation.

My view contains a page display with the following path set: blog/%/%/%

Here is a sample path argument of what I'm trying to accomplish: Path URL: blog/7/node-title/taxonomy-name

if ( is_numeric(arg(1)) && is_string(arg(3)) ) {   
//check to make sure arg 1 is text and arg 2 is a string

  $node = node_load(arg(1));
//load the node

  $terms = taxonomy_get_term_by_name(arg(3));
//get the terms array and TID from arg 3.

  if (!empty($terms)) {
    $first_term = array_shift($terms);
    foreach($node->field_repair_states_region['und'] as $x => $y) {
      if( $y['tid'] == $first_term->tid ) { return TRUE; }
//make sure the TID matches the TID to the node.

    } 
  }
}

Screenshot of Validation Page: http://prntscr.com/1dcl4v

Screenshot of View: http://prntscr.com/1dclly

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.