Render a view programmatically with contextural Contextual Filters (arguments)

WE HAVE MOVED!

Please visit our new Drupal Website at https://www.xenyo.com我們的新網頁設計公司網頁.

/*    method 1   */
global $user;
$arg1 = $user->uid;
$arg2 = 1; // may be nid .. the second Contextual Filter argument
print views_embed_view('view_name', 'display_id', $arg1, $arg2);
 
/*    method 2   */
$view = views_get_view('view_name');
$view->set_display('display_id');
$args = array($arg1, $arg2);
$view->set_arguments($args);
$view->pre_execute();
print $view->render(); 
Help Share this Article