I would like to check if particular node instance exists then load that node. if the instance does not exist, then display message. So far:
function MODULE_menu() {
$items['ds-some'] = array(
'title' => 'Some',
'page callback' => 'some_display',
'access arguments' => array('access content'),
'type' => MENU_NORMAL_ITEM,
'file' => 'inc/some.pages.inc',
);
return $items;
}
function MODULE_theme(){
return array(
'render-some' => array(
'template' => 'page--some',
'variables' => array(
'node' => NULL
),
'path' => path_to_theme().'/templates',
),
);
}
in file inc/some.pages.inc
function some_display(){
$build = array();
$nid_some = db_select('node', 'n')
->fields('n', array('nid'))
->fields('n', array('type'))
->condition('n.type', 'SOME_TYPE')
->execute()
->fetchCol();
//load first instance
$someNode = node_load($nid_some[0]);
if (!empty($shopNode)) {
//Attempt 1
// $build['ds-some'] = array(
// '#theme' => 'node',
// '#node' => $someNode,
// '#view_mode' => 'full',
// );
//Attempt 2
// $build['ds-some'] = node_view($someNode, 'full');
$build['ds-some'] = array(
'#theme' => 'render-some',
'#node' => $someNode,
);
}
else {
drupal_set_message(t('It appears there is no instance present');
}
return $build;
}
The first two attempts ended with the title of the Node instance but Drupal is no rendering the whole page(template file, views, etc). In my last attempt, i use custom theme function that it works, however. It is not rendering the context for the node type specified. How to specify context when working with hook_menu(), so that the context configured will load blocks and views? Thank you for any help.
context configured
? Are talking about Context module?