I am trying to conceptualize a project and am stumped on the following part.

I am going to have various content types that all have a taxonomy term of either US or International. I plan to set the user's location in the session variable:

$_SESSION['locale'] = 'US';

Question: Can I create a view that will show a content type and filter it to show only it's node's whose taxonomy also matches the locale session variable.

Example:

PRODUCT
Product A: contains US information: Taxonomy Location = US
Product A: contains INT information: Taxonomy Location =INT

Using this example, and assuming the session variable is set to 'US', how can I set a view to display Product A whose taxonomy term is set to US?

Comments

3cwebdev’s picture

I was able to adapt a snippet I found in a handbook.

My solution was to create a view argument by Taxonomy Term.

Set it to Provide Default Argument->PHP Code

$arg = '';

switch ($_SESSION['location']){
  case 'us':
    $arg = 'US';
    break;
  case 'int':
    $arg = 'International';
    break;
}

return $arg;

This will show my products whose Taxonomy Term match the $_SESSION variable that I set earlier.

dawehner’s picture

Status: Active » Fixed

thx for finding it yourself :)

so this can be marked as fixed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.