7

I have a context set up:

Condition > taxonomy term > vocabulary.

Reaction > some blocks displayed somewhere

This works ok for path like taxonomy/term/term_id but it doesn't work for something like taxonomy/term/term_id_1+term_id_2

Any ideas? Thanks

0

This is a bit of code can help you I hope,

 <?php
   check_vocabulary = FALSE;
     $path = drupal_get_path_alias($_GET['q']); 
     $pathnew = explode('/', $path);
     if ($pathnew[2]) {
        $vocabulary = explode('+', $pathnew[2]);
     }
    if ($vocabulary[0] == "your taxonomy") {
       check_vocabulary = TRUE;
    }
  return check_vocabulary;
?>

You should put it in the block under the tab Page specificy visibility setting, click on Show if the following PHP code returns TRUE (PHP-mode, experts only).

Now I'm not sure it's going to work with your setting and name but it could be a way for a solution.

 check_vocabulary = FALSE;

As we know, the system wants you to return TRUE to print the block so we set it false in the beginning so it's no going to print it and then remove it.

$path = drupal_get_path_alias($_GET['q']); 
$pathnew = explode('/', $path);

In this part we take the path and we explode it so we get an array like this.

$pathnew[0]; Taxonomy
$pathnew[1]; Term
$pathnew[2]; Term_id_1+term_id_2

if ($pathnew[2]) {
    $vocabulary = explode('+', $pathnew[2]);
  }

We check first that $pathnew[2] exists and then we explode it to get all the vocabularies (if you want it separated). We split it by + so you will get

$vocabulary[0]; Term_id_1
$vocabulary[1]; term_id_2

Now we create the condition;

if ($vocabulary[0] == "your taxonomy") {
   check_vocabulary = TRUE;
}

You can compare what you want, that is just an example.

check_vocabulary = TRUE;

This is what the system wants to print the block.

return check_vocabulary;

This will return the variable FALSE or TRUE.

Let me know if it works.

  • I know how to do it myself with custom code but I need to do it with Context module. – Marius Ilie Jun 18 '12 at 16:10
0

Can you not change the condition to just be the vocabulary and not the term? That way it will work with any term in that vocabulary?

Also you could use the path as a condition:

taxonomy/term/*

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.