1

I am trying to get a taxonomy parent name with this code; when I put 1 as the argument, I keep getting the ID, but when I try using 2, I get a error. It should wor,k but it keeps throwing the error back at me. I am trying to get the parent name, not the ID.

$view = views_get_current_view();
print $arg0 = $view->args[2];

Notice: Undefined offset: 2 in __lambda_func() (line 3 of /home/loansdotorg/public_html/modules/views_php/plugins/views/views_php_handler_area.inc(39) : runtime-created function).

1
  • i have the same issue, and I have no idea of what's wrong. All works, but the notice still appears. – user1297 May 16 '11 at 17:22
1

I believe that Views uses $view->args to store the arguments it has received from the url, or passed to it when embedded.

So in the above case, you would need a url structure where the parent term is located in the views url after the actual term. Most likely this is not the case.

If you want to get the parent term you can use the function taxonomy_get_parents

1
  • ok so i have this but it returns just the word array not the taxonomy term, any idea what im missing? <?php $view = views_get_current_view(); $arg0 = $view->args[0]; print taxonomy_get_parents($arg0); ?> – Jeremy Love May 7 '11 at 16:34

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.