Very useful lines of code to embed "Views 2" views into your nodes.
Works almost as the old
<?php
$view = views_get_view('views_name');
print (views_build_view('embed', &$view, array(), $view->use_pager, $view->nodes_per_block));
?>in Drupal 5 but for Drupal 6. This is also a way to embed views programatically into your pages and nodes.
The following lines of code will load a view and print the display.
<?php
$view = views_get_view($viewname);
$view->set_arguments( array( $arg ) );
$view->set_display($displayId);
$view->set_items_per_page($number);
$view->execute();
$count = count( $view->result );
print $view->preview($display_id, $args);
?>The following line will print the output of a view. You can pass it the display name to show any display you want. And also the arguments if any.
<?php
print views_embed_view($viewname, $display_id = 'default', $arg1, $arg2);
?>Here is a very nice article about it http://api.freestylesystems.co.uk/api/function/views_embed_view/6
Another good source for manipulating and embedding your views 2 http://thedrupalblog.com/category/tags/set-display
Another good resource http://views2.logrus.com/doc/html/classview.html#d1f69acfdb3771ec2d6f54f... Not the easiest to understand though
Post new comment