In a Views field handler, one can define additional fields to accompany the base field defined in hook_field_data. These field values are based on database columns on the same row, and they can be used in the render function. Somewhat like this:
my_views_field_handler extends views_handler_field {
function construct() {
parent::construct();
$this->additional_fields['property2'] = 'property2';
}
function render($values) {
return $this->get_value($values) . $this->get_value($values, 'property2');
}
}
But is it also possible to define a join in the constructor? One of my database columns is an id of another entity. I have been using it somewhat like this, but this generates quite a lot of overhead (loading an entire entity for each row).
function render($values) {
$id = $this->get_value($values, 'property2');
$entity = entity_load_single('my_type', $id);
if ($entity->some_other_field == TRUE) {
return $this->get_value($values);
}
else {
return 'none';
}
}
So is there something like a join I can use in the constuctor, so I can query the other entity table directly instead of having to load the entity?