I have a view that uses the id of the currently logged in user as a contextual filter. This was set using the Drupal UI and works well. Then I wrote a custom module that adds another parameter (a specific node id) to all views on my site. All views need this second parameter (and it needs to be added programmatically). This approach works well for all views that only use the programmatically added parameter as a contextual filter. However, the view that needs 2 filter values does not work, because I think I do not handle the order of parameters in the args array correctly. How do I set up views that already use filter values, but I need to add more programmatically (I set $args[0], but I guess this might be the problem) ?
I should say that I do not want those filters to appear in the URL.
testmod.module:
function testmod_views_pre_view($view, $display_id, array &$args) {
...
$args[0] = $value;
}
I thought I could just read the view's $arg array and add my special argument to it programmatically, but for the view that already uses the logged-in user as a contextual filter, when I print print_r($args) it is an empty array, although the view is working correctly (and only shows results for the current user). Are contextual filters that I set up via the UI stored in a different place than $args ?
What needs to be done to tell the view how to use the 1. and 2. filter values correctly ?
Edit: I read that hook_views_pre_view() is too early to find contextual filters in the arg array (at that point you would only see arguments in that array passed via URL). Which hook would be best to achieve what I'd like to do ?