这是vegas.module文件的代码。它用于从特定文件夹加载图像。从drupal模块打印主题文件中的变量
function vegas_init() {
// Load all the images to be added to Vegas.
$backgrounds = array();
$fade = variable_get('vegas_fade', 0);
for ($i = 0; $i < 10; $i++) {
$fid = variable_get('vegas_images_' . $i, '');
if (!empty($fid)) {
$image = file_load($fid);
if ($image) {
$background = array(
'src' => file_create_url($image->uri),
);
if (!empty($fade)) {
$background['fade'] = intval($fade);
}
$backgrounds[] = $background;
}
}
}
我将它打印在.module文件中。它给出了预期的结果。
print_r($backgrounds);
如果我打印它在我的主题的page.tpl.php它不会返回任何值。是否有任何方法加载模块的变量
为什么我应该把这个函数放在template.php –
如果有些开发者在你改变你的模板文件之后 - 他会在一个文件中看到模板变量的所有变化,他不会在模块中搜索这个变化。 – DrHolera
谢谢DrHolera博士 –