I know I can insert a view using the following code:

    $view = views_get_view('VIEWNAME');
    print $view->preview('default');

In my view I have a contextual filter of user: name

When I insert this view using the Display Suite module I have this option from Display Suite:

enter image description here

I was wondering if there is a way to pass this context to the view, like Display Suite does, using php code only.

1 Answer 1


You can set the default value for the contextual filter through URL and then in your code use $view->set_arguments() to pass the argument.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.