我想在drupal中将模块中的值传递给页面tpl文件。我已经创建了一个自定义模块&one;时间_popup'。我创建了一个示例soutput并尝试传递它并在page.tpl中打印.php在页脚部分之后。但是没有显示任何东西。我做错了什么。我是新手
function one_time_popup_menu(){
$items['oneTimePopupData'] = array(
'title' => 'One time Popup',
'page callback' => 'one_time_popup_user_login',
'type' => MENU_CALLBACK,
'access callback' => TRUE,
);
return $items;
}
function one_time_popup_user_login(&$edit, $account){
...
$output='value from one time popup module!';
return theme('photo_order',array('results' => $output));
}
function one_time_popup_theme() {
return array(
'photo_order' => array(
'template' => 'page',
'variables' => array(
'results' => NULL,
),
),
);
}
Tpl file(page.tpl)
<?php echo $results; ?>
答案 0 :(得分:0)
希望这有助于你
function one_time_popup_menu(){
$items['popuppage'] = array(
'title' => 'One time Popup',
'page callback' => 'one_time_popup_page',
'type' => MENU_CALLBACK,
'access arguments' => array('access content'),
);
return $items;
}
function one_time_popup_page(){
$output = 'value from one time popup module!';
return theme('photo_order',array('results' => $output));
}
function one_time_popup_theme() {
$path = drupal_get_path('module', 'one_time_popup');
return array(
'photo_order' => array(
'variables' => array('results' => null),
'template' => 'photo_order',
'path' => $path,
),
);
}
将您的tpl文件 photo_order.tpl.php 放入您的模块目录,并在其中使用以下代码。
<?php print $results; ?>
或
function one_time_popup_theme() {
return array(
'photo_order' => array(
'variables' => array('results' => null),
'template' => 'photo_order',
),
);
}
将您的tpl文件 photo_order.tpl.php 放在您的主题目录中,并在其中放置以下代码
<?php print $results; ?>