I´m using the following code to retrieve the taxonomy id from the URL and use it as a contextual filter.
When I use it on a computed field as it is shown below it works OK.
$nid = arg(1);
$path_alias = drupal_get_path_alias('node/' . $nid);
$partes = explode("/", $path_alias);
$dato = $partes[2];
$entity_field[0]['value'] = $dato;
When I use the same code on a views contextual filter it doesn´t work:
$nid = arg(1);
$path_alias = drupal_get_path_alias('node/' . $nid);
$partes = explode("/", $path_alias);
$dato = $partes[2];
return $dato;
If I replace line 4 to force a value into $dato it works OK too, of course for only one taxonomy term.
$nid = arg(1);
$path_alias = drupal_get_path_alias('node/' . $nid);
$partes = explode("/", $path_alias);
$dato = 43;
return $dato;
I would like to receive any help on what I need to correct on the second example to make it work as a contextual filter.
Thanks!
Comments
Comment #2
Subhransu.addweb commentedCan you please give URL from which you get tid. From your code it seems that you are getting nid from URL.
Thanks!
Comment #3
glanster commentedHi!
The URL can be something like the following:
http://localhost/GLSIMBDES/?q=content/72067/45
I´m quite sure that the code returns the tid because when I use it on a computed field as in the first example it works OK and it displays the tid. I´m using 2 as index for the "exploded" variable.
The problem is that the same code does not work on a contextual filter. It does if I force the value as in the third example.
Comment #4
glanster commentedComment #6
glanster commentedAfter some new tests I found that the problem is related with Entity References View Widget so I´m transferring the support request to that module issue´s page.
https://www.drupal.org/node/2629966
Comment #7
mustanggb commentedComment #8
renatog commentedPerfect @glanster.
Let's follow the issue on Issue Queue of Entity Reference View Widget
Thank you very much.
Regards
Comment #9
renatog commented