Drupal multiple Views on same page
If you’re using Drupal 6.x and you need to display multiple ‘Views’ on your homepage (or any other page for that matter) here’s the code that will do it for you…
In this example I will be displaying the View called ’showcase’, just change it to whatever name you called your View. The only text you need to change is highlited in red.
You can paste this code into your page.tpl.php file for as many Views as you need!
<?php $viewname = 'showcase'; $display_id = 'showcase'; // or any other display $args = array(); $args [0] = 'foo'; // These values are optional $args [1] = 'bar'; $view = views_get_view($viewname); $view->set_display($display_id); $view->set_arguments($args); print $view->preview(); ?>
If you just want to display a View without passing in any variables (args) then you can simply have:
<?php
$viewname = 'showcase';
$display_id = 'showcase'; // or any other display
$view = views_get_view($viewname);
$view->set_display($display_id);
print $view->preview();
?>
Boom! Job done.
All the best
Simon
Related posts:
- Drupal 6.x Why do I see candidate function names and not candidate template files?
- Drupal Clear Top ‘page not found’ errors – How to?
- Drupal – The selected file… could not be uploaded. Only JPEG, PNG and GIF images are allowed
- IIS and Drupal – Enable Clean URL’s
Tags: drupal
This entry was posted on Friday, October 9th, 2009 at 5:19 pm and is filed under Articles & Reviews.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.
Leave a Reply
Hot Topics
- Creating a Drupal 6 custom login form - Step by Step tutorial.
- WordPress Contact Form 7 & WP-Mail-SMTP problem solved
- imagecache wrong path - SOLVED!
- Adobe Contribute CS4 - cannot verify your connection Information.
- IIRF Drupal, WordPress and IIS6 - How to get them working first time - Guaranteed!
- Drupal - The selected file... could not be uploaded. Only JPEG, PNG and GIF images are allowed
- Learning About Drupal
- Feeling sick after watching IMAX - Avatar
- Wordpress widgets not saving or dragging?
- How to take Ownership of a Drive, Folder or File in Windows 7
- 7129/6105195 Edward Leedskalnin's anti-gravity - How he built Coral Castle.
- Why do I need to keep resetting my router?
- IIS and Drupal - Enable Clean URL's
- IIRF Wordpress - URL Rewriting for IIS6.0
- Windows 7 Problems.
- Drupal mailhandler smtp localhost error
- Is it Moore's Law or the Microsoft Inverse Square Law?
- Contact
- Drupal Gmail Module - Solved.
- IIS7 - No HTTP redirect icon
