You are here

function nodeblock_preprocess_node in Nodeblock 7

Same name and namespace in other branches
  1. 6 nodeblock.module \nodeblock_preprocess_node()

Implements hook_preprocess_node().

Adds theme hook suggestions for nodeblock enabled nodes in this order:

  • node--nodeblock.tpl.php
  • node--nodeblock--default.tpl.php,
  • node--[content-type].tpl.php
  • node--nodeblock--[content-type].tpl.php
  • node--[nid].tpl.php
  • node--nodeblock--[nid].tpl.php.

File

./nodeblock.module, line 925
Enables use of specified node types as custom blocks.

Code

function nodeblock_preprocess_node(&$variables) {
  if (isset($variables['nodeblock']) && isset($variables['nodeblock']['shown_as_block'])) {

    // Make sure content type is added
    // between the node--[nid] and node--[content-type] suggestion.
    array_splice($variables['theme_hook_suggestions'], 1, 0, array(
      'node__nodeblock__' . $variables['node']->type,
    ));

    // Make sure content type is added as the first suggestion.
    $variables['theme_hook_suggestions'][] = 'node__nodeblock__' . $variables['node']->nid;

    // Set these as the last suggestions.
    array_splice($variables['theme_hook_suggestions'], 0, 0, array(
      'node__nodeblock',
      'node__nodeblock__default',
    ));
  }
}