How to programmatically select a view display in a view based on some node data I have a content type that includes a field to store how that node should be displayed (display_option). display_option has two values (1|2).

I have created a view with two displays. Both are pages. Both use the path /node/% and use the node id as a contextual filter.

Display 1 has an additional filter criteria for requiring that display_option = 1.

Display 2 has the same filter but with the criteria that display_option = 2.

I can supply a node id to each display preview and they both individually produce the content I am looking for.

I was hoping Drupal would simply select the correct display based on the filter criteria but it doesn't. It always uses the display that is first in the view.

So I was looking at adding a pre-process function of some kind to template.php to manually change the view display id based on the node data.

I see quite a few views pre-processing functions and I am not sure which to use or at what point in the page build and view build process.

Any help would be appreciated including another method for accomplishing this.
The simple way to do this is 

print $view views_get_view('yourviews_name','yourdisplayname');


for more information you can read documentation here