Drupal html输出主题
我有一个自定义模块,可以生成一页输出,我的问题是如何向输出中添加html元素,如标题和段落等 我的模块如下Drupal html输出主题,drupal,drupal-7,drupal-modules,drupal-themes,Drupal,Drupal 7,Drupal Modules,Drupal Themes,我有一个自定义模块,可以生成一页输出,我的问题是如何向输出中添加html元素,如标题和段落等 我的模块如下 function mymodule_page() { $output .= '<h3>'.t('Installs '.$cell).'</h3>'; $output .= theme('flot_graph', $graph1); return $output; } 函数mymodule_page(){ $output.=''.t('安装'.$cell.''; $
function mymodule_page() {
$output .= '<h3>'.t('Installs '.$cell).'</h3>';
$output .= theme('flot_graph', $graph1);
return $output;
}
函数mymodule_page(){
$output.=''.t('安装'.$cell.'';
$output.=theme('flot_graph',$graph1);
返回$output;
}
这是正确的方法吗
第二行应该是这样吗
$output .= t('<h3>Installs '.$cell.'</h3>');
$output.=t('Installs'.$cell');
我不希望在模块文件中混合逻辑和表示,因此我会使用tpl打印内容。例如,在您的模块中,我将输入以下代码:
function mymodule_page() {
return theme_render_template(drupal_get_path('theme', 'your_theme') . 'path/to/your/file.tpl', array('cell' => $cell, 'graph1' => $graph1);
}
在tpl文件中:
<h3><?php echo t('Installs') . ' ' . $cell; ?></h3>
theme('flot_graph', $graph1);
主题('flot_graph',$graph1);
我是否应该在我的模块目录中创建一个名为theme的目录,然后只创建creare mymodule.tpl.php?是的,这没有问题,这样你就可以独立于主题来创建模块,这是一个好主意。实际上,我必须在像这样的关联数组中传递变量('cell'=>$cell',graph'=>$graph);