Skip to content

Instantly share code, notes, and snippets.

@allgood2386
Created December 11, 2013 17:06
Show Gist options
  • Save allgood2386/7914430 to your computer and use it in GitHub Desktop.
Save allgood2386/7914430 to your computer and use it in GitHub Desktop.
How to embed a view via hook_node_view
<?php
function mymodule_node_view($node){
switch($node) {
case $node->nid == 'the node id here':
$node['someLogicalNameHere'] = array (
'#type' => 'markup',
'#markup' => views_embed_view($viewName, $display_name);
//to get view name click on edit in views_ui and select your display, the url will have the following format:
// admin/structure/views/view/$viewName/edit/$display_name
//if you want to change the $display_name click advanced in the view and look for machine name about halfway down. Care
//when changing this you might have to reset context and blocks cause they use the machine name, the default patter is
//page, page_2, page_3, block, block_2, etc.
);
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment