Enhanced_taxonomy field not shown in views header/empty text
Summit - December 5, 2008 - 12:43
| Project: | Taxonomy Enhancer |
| Version: | 5.x-2.x-dev |
| Component: | Code - Taxonomy Enhancer |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
Hi,
I try to get a field which I added to my vocabulary in my view as explained on: http://drupal.org/node/292758
My url has the following arguments : vakgebied/amerikaans-nederlandse/juridische-vertaling
arg(0)=vakgebied, arg(1)= amerikaans-nederlandse and arg(2) = juridische-vertaling (It is dutch :)
I got from term-name to term-id by function: taxonomy_get_term_by_name
The field which I added has the id "price".
I try to get the following into my view-header and empty text:
<?php
$t = taxonomy_get_term_by_name(arg(2));
taxonomy_enhancer_extend_term($t);
print_r ($t->my_price_field_id);
?>The output says I have the correct term, but the enhanced taxonomy field is not shown under the normal $t output.
Instead this is my error message I got.
warning: Attempt to assign property of non-object in modules/taxonomy_enhancer/taxonomy_enhancer.module on line 264.Can anyone help with this please?
Thanks a lot in advance!
Greetings,
Martijn

#1
Hi,
A couple things to add after more testing.
My view is not the taxonomy/term view. I got the price shown with your method on http://drupal.org/node/292758 on the regular taxonomy/term view.
Result on taxonomy/term view amerikaans-nederlandse/juridische-vertaling (urlalias) with code:
<?php$t = taxonomy_get_term(arg(2));
taxonomy_enhancer_extend_term($t);
print_r ($t);
?>
stdClass Object ( [tid] => 91 [vid] => 4 [name] => juridische-vertaling [description] => Juridische vertaling is een vertaling die de juiste juridische termen bevat [weight] => 0 [pid] => 0 [price] =>20 eurocent per woord)Shown enhanced field: [price] =>20 eurocent per woord
result on view: vakgebieden/amerikaans-nederlandse/juridische-vertaling
<?php$t = taxonomy_get_term_by_name(arg(2));
taxonomy_enhancer_extend_term($t);
print_r ($t);
?>
Array ( [0] => stdClass Object ( [tid] => 91 [vid] => 4 [name] => juridische-vertaling [description] => Juridische vertaling is een vertaling die de juiste juridische termen bevat [weight] => 0 [pid] => 0 ) )Not shown enhanced field: [price] =>20 eurocent per woord
While the same code using taxonomy_get_term instead of taxonomy_get_term_by_name gives [price] value on taxonomy/term view.
Is there a difference between coming from taxonomy_get_term_by_name and taxonomy_get_term for having the $t ?
Or is there somewhere a difference within taxonomy_enhancer?
Thanks a lot in advance for going into this!
Greetings,
Martijn
#2
Hi,
It looks that the function get_term_by_name does'nt get the "enhanced" fields shown...
My code to bypass this is the following, but may be somebody has an better option:
<?php$t = taxonomy_get_term_by_name(arg(2));
$t = taxonomy_get_term($t[0]->tid);
taxonomy_enhancer_extend_term($t);
print 'Prijs: ' . $t->price;
?>
Greetings,
Martijn