0

This question already has an answer here:

I am attempting to render a menu assigned to a block right next to the body of a custom content type. I am using Drupal 7.

I have a custom region defined within my template .info file. I would like to render this region and the block assigned to it from within a custom node template ...

node--<my custom content type>.tpl.php

I needed to do this within the custom node template because I needed to break out the individual fields of the content type rather than just using

print render($content);

This is what I was trying to do ...

<div class="content">
  <?php
    print render($content['title']);
    print render($content['field_banner_image']);
    print render($content['body']);
  ?>
  <div><?php print render($page['MY-CUSTOM-REGION']); ?></div>
  <div><?php print render($content['body']); ?>div>
</div>

However, my menu block does not render and I get the following error ...

Warning: Cannot use a scalar value as an array in include()[PATH TO MY CUSTOM NODE TEMPLATE]

Is it possible to render a region from within a custom node template?

marked as duplicate by Mołot, monymirza, Free Radical, Triskelion, Patrick Kenny Jul 14 '13 at 14:47

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    I found a solution from drupal.stackexchange.com/questions/20054/…. Basically I need to add a function to the template.php file for my theme. Once I did that the node tamplate was "aware" of my custom region and I was able to render it. The above article has a very thorough and detailed explanation. – webworm Nov 23 '12 at 15:22
  • 1
    could you post your solution as an answer and check it? it will hep others to identify quickly the solution :) – cayerdis Nov 23 '12 at 15:58
  • 1
    @cayerdis don't repost answers, mark as duplicate. – Mołot Jul 12 '13 at 8:13
0

You should load your menu yourself inside node, use:

  1. hook_node_load
  2. hook_node_view
  3. hook_preprocess_node

Not the answer you're looking for? Browse other questions tagged or ask your own question.