我需要将变量从views-view-unformatted.tpl.php传递到page.tpl.php。
所以 views-view-unformatted.tpl 的代码.php:
<?php if (!empty($title)): ?>
<h3><?php print $title; ?></h3>
<?php endif; ?>
<?php foreach ($rows as $id => $row): ?>
<div<?php if ($classes_array[$id]) { print ' class="' . $classes_array[$id] .'"'; } ?>>
<?php print $row; ?>
<?php if(condition): ?>
<?php $my_var = array('val_1','val_2','val_3'); ?>
<?php endif; ?>
</div>
<?php endforeach; ?>
结果我想要这样的东西:
...
<div class="footer">
foreach ($my_var as $val) {
print $val . <br>;
}
</div>
...
可以在page.tpl中打印.php在views-view-unformatted.tpl.php中生成的变量?
谢谢!
我通过使用找到了解决方案
/**
* Implements hook_preprocess().
*/
function mytheme_preprocess(&$variables, $hook) {
.. my code here ..
}
从这里