0
votes

I've got a session variable containing an ever changing city name.

Example - $_Session['Toronto'];

I've also got a list of unfiltered nodes with lots of fields. Most importantly they have a taxonomy term field called 'city'.

I need to be able to only display the nodes with the taxonomy terms that match the $_Session['Toronto'].

Example - Node 9 and 10 have taxonomy terms of 'Toronto' and 'Ottawa'. I will only want the node with the term of 'Toronto' to display on the page.

Any help?

1

1 Answers

1
votes

With views, you can use hook_views_query_alter

D7 example

function YOURMODULE_views_query_alter(&$view, &$query){

  switch ( $view->name ){
    case 'YOURVIEWNAME':    
      $query->where[1]['conditions'][] = array(
        'field' => 'term_field_name', //your term name in the sql query
        'value' => $_Session['Toronto'],
        'operator' => '='
      );
      break;
  }
}