区域模板中的Drupal变量

I'm doing my first totally custom Drupal 7 theme. I have the page.tpl.php file working fine and have header and footer regions working, until I move this:

<?php print render($page['main_menu']); ?>

into region--header.tpl.php - the menu is no longer generated - the html around the PHP is generated - nav etc. so I know drupal's reading the template file OK.

The same code works fine if it is in page.tpl.php

Any help greatly appreciated.

1个回答

Main menu available as block. So you can just put him to this region. It's good practice. Also don't forget to clear drupal/browser cache.

If you define custom variable in preprocess_page() or any other preprocess functions you shouldn't use render function, just use print $main_menu for example.

Also try check this

展开翻译

译文



主菜单可用作块。 所以你可以把他带到这个地区。 这是一个很好的做法。
也不要忘记清除drupal /浏览器缓存。</ p>

如果你在 preprocess_page()</ code>或任何其他预处理函数中定义自定义变量你 不应该使用渲染功能,只需使用 print $ main_menu </ code>。</ p>

同时尝试检查 this </ p>
</ div>

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问