http://drupalcontrib.org/api/function/views_embed_view/6
This code embeds the view block as is. The first variable is the NAME of my view. the second is the NAME of the block. Still not quite sure how to figure out the name since it is actually called reflections_block, but views seems to give generic numbers.
Note that this function passes any additional parameters to the View as Arguments.
Use page_1, page_2, block_1, block_2, … as $display_id. You’ll see the display IDs when hovering over the display names in Vews UI or in the URL when editing the displays.
#000000">#0000BB"><?php
#007700">print #0000BB">views_embed_view#007700">(#DD0000">'archive_reflections'#007700">, #DD0000">'block_1'#007700">);
#FF8000">/**
* Embed a view using a <span class="caps">PHP</span> snippet.
*
* This function is meant to be called from <span class="caps">PHP</span> snippets, should one wish to
* embed a view in a node or something. It's meant to provide the simplest
* solution and doesn't really offer a lot of options, but breaking the function
* apart is pretty easy, and this provides a worthwhile guide to doing so.
*
* @param $name
* The name of the view to embed.
* @param $display_id
* The display id to embed. If unsure, use 'default', as it will always be
* valid. But things like 'page' or 'block' should work here.
* @param …
* Any additional parameters will be passed as arguments.
*/
#007700">function #0000BB">views_embed_view#007700">(#0000BB">$name#007700">, #0000BB">$display_id #007700">= #DD0000">'default'#007700">)#0000BB"> #007700">{#0000BB">…
?>The code below embeds the view as well as the Title of the block. The code above only embeds the block itself, the title is a separate function.
#000000">#0000BB"><?php
$view #007700">= #0000BB">views_get_view#007700">(#DD0000">'archive_reflections'#007700">);
#0000BB">$view#007700">->#0000BB">set_display#007700">(#DD0000">'block_1'#007700">);
#0000BB">$output #007700">= #0000BB">$view#007700">->#0000BB">preview#007700">();
#0000BB">$title #007700">= #0000BB">$view#007700">->#0000BB">get_title#007700">();
print #DD0000">'<div class="title">' #007700">. #0000BB">$title #007700">. #DD0000">'</div>'#007700">;
#0000BB">print $output#007700">;
#0000BB">?>


Add your comment