Altering relationship in Views contextually I need to alter a Views relationship contextually: since the View is embedded into another node, the relationship is defined by a field's value of a parent node. 

I presume the only way to add a relationship is using hook_views_data_alter, but I'm not quite sure if it's going to work inside a preprocessor function (I'm creating a View for a certain node type) and what's the proper way of using it. The related field will be a Nodequeue instance (Nodequeue module is integrated with Views using relationships), its name will be contained in that parent node's field.

Thanks in advance!
I did eventually discover simple solution, so perhaps it comes in handy for anyone else later. views_data_alter, of course, is not meant to apply an existing relationship, but rather to create a new one. To apply an existing relationship programmatically - Nodequeque in my case - you need to call in add_item function of view class:

$view-&gt;add_item($view-&gt;current_display, 'relationship', 'node', 'nodequeue_rel', array('names'=&gt;array('myqueue'=&gt;'myqueue'), 'required'=&gt;1, 'limit'=&gt;1))


where an array is a set of options like: the name(s) of queue(s) and whether any nodes excluded from chosen queque(s) should be added (1 - bool - implies that only nodes inside the chosen queque will be added).