For the life of me I can't figure this out.
I have vast and complicated drupal 7 site and among other things I'm using profile2 module. Not sure why, but a few years back I've added field directly to 'profile' table. It is used to store some number and adding it looked like quick fix back then.
Now I need to get some info using views and all is fine except this one field which I absolutely have to take into account, but I am not able to.
What I did so far is:
function modulename_views_api(){
return array(
'api' => 3,
'path' => drupal_get_path('module', 'modulename'),
);
}
in my custom module,
function modulename_views_query_alter(&$view, &$query){
if ($view->name == 'viewname') {
$query->add_field(NULL, 'some_field', array());
}
}
in modulename.views.inc
What I'm trying to do is either add this field to display directly, or add it to the list of fields, or replacement patterns, or anything I could use.
modulename_views_data()
isn't useful for me, because I would have to recreate whole table structure created (and frequently changed) in GUI.
I tried _views_pre_view, _views_pre_render, relationships, query rewrites, all to no avail. I've run out of ideas...
hook_views_data_alter()
$r->my_field[]['rendered']['#markup']
, but it didn't work, either.