Drupal 部分未显示
Drupal Partial not being displayed
我有部分页脚
templates/partials/footer.tpl.php
页脚..
我已将它添加到我的 template.php 文件中的 theme() 挂钩中
template.php
function scratch_theme($existing, $type, $theme, $path){
return array(
'footer' => array('template' => 'templates/partials/footer'),
);
}
但是当我调用它时它不显示
页.tpl.php
<?php $mainMenu = scratch_get_main_menu(); ?>
<div class="menu">
<ul>
<?php foreach($mainMenu as $item){
echo "<li>" . $item['link']['link_title'] . "</li>";
}?>
</ul>
</div>
我已经转储了 var 但没有,我只得到一个空字符串
非常感谢任何帮助
您错过了 the docs 中的这一点:
Each information array must contain either a 'variables' element or a 'render element' element, but not both
所以:
function scratch_theme($existing, $type, $theme, $path){
return array(
'footer' => array(
'template' => 'templates/partials/footer',
'variables' => array(),
),
);
}
清除缓存应该可以解决这个问题
我有部分页脚
templates/partials/footer.tpl.php
页脚..
我已将它添加到我的 template.php 文件中的 theme() 挂钩中
template.php
function scratch_theme($existing, $type, $theme, $path){
return array(
'footer' => array('template' => 'templates/partials/footer'),
);
}
但是当我调用它时它不显示
页.tpl.php
<?php $mainMenu = scratch_get_main_menu(); ?>
<div class="menu">
<ul>
<?php foreach($mainMenu as $item){
echo "<li>" . $item['link']['link_title'] . "</li>";
}?>
</ul>
</div>
我已经转储了 var 但没有,我只得到一个空字符串
非常感谢任何帮助
您错过了 the docs 中的这一点:
Each information array must contain either a 'variables' element or a 'render element' element, but not both
所以:
function scratch_theme($existing, $type, $theme, $path){
return array(
'footer' => array(
'template' => 'templates/partials/footer',
'variables' => array(),
),
);
}
清除缓存应该可以解决这个问题