Last active
December 22, 2015 13:29
-
-
Save esafwan/6479466 to your computer and use it in GitHub Desktop.
Load view and then set its display, limit how much to load, pass argument and then render all programatically. Easy snippet or example code.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Load the view. | |
$view = views_get_view('news_master'); | |
//set the display. | |
$view->set_display('block'); | |
//set the limit. | |
$view->set_items_per_page(8); | |
//set offset | |
$view->set_offset(5); | |
//pass the arguments. | |
$view->set_arguments(array($tid)); | |
//setting the page, so that its show. | |
$pager = $view->display_handler->get_option('pager'); | |
$pager['type'] = 'mini'; //or 'full' | |
$view->display_handler->set_option('pager', $pager); | |
//compulsory if you want the cache & all to work. | |
$view->pre_execute(); | |
//execute everything. | |
$view->execute(); | |
//render the final output | |
$content = $view->render(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment