Embedding Views snippet

Embedding Views snippet

21 June 2010 by jay boodhun Embedding Views snippet 0 Comments

This snippet is useful if you want to embed views in your content without having to install modules to do this small task.

Below is ths snippet

  
<?php
$view = views_get_view($view_name);
$display_id = 'page_1'; // Can be feed_1 or block_1
$view->set_display($display_id);
$view->preview = TRUE;
$view->pre_execute(array()); //args
$view->is_cacheable = FALSE;
$data = $view->render($display_id); // render
print $data;
?>
 

Below are the modules that can also help achieving this:

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
  • Syntax highlight code surrounded by the {syntaxhighlighter OPTIONS}...{/syntaxhighlighter} tags.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.