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 Change Publishing options
- “defizet” This is a test word to see how quickly this page gets indexed by Google
- Drupal – The selected file… could not be uploaded. Only JPEG, PNG and GIF images are allowed
- “Increase Google Page Rank” It’s official – I now hate Google.
- Access denied – Drupal 6.x
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.
2 Comments
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!
- 7129/6105195 Edward Leedskalnin’s anti-gravity – How he built Coral Castle.
- How to take Ownership of a Drive, Folder or File in Windows 7
- WordPress widgets not saving or dragging?
- Firefox – update favicon.ico (SOLVED)
- IE emulator for FireFox
- Site off-line The site is currently not available due to technical problems. Please try again later. Thank you for your understanding. (SOLVED!)
- Access denied – Drupal 6.x
Archives
- November 2011
- September 2011
- August 2011
- June 2011
- January 2011
- December 2010
- November 2010
- October 2010
- May 2010
- April 2010
- March 2010
- February 2010
- January 2010
- December 2009
- November 2009
- October 2009
- September 2009
- August 2009
- July 2009
- June 2009
- May 2009
- April 2009
- January 2009
- December 2008
- August 2008
- June 2008

Thank you very much! That was extremely simple and very very useful!
Thanks, that’s exactly what I was looking for.