Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Drupal html输出主题_Drupal_Drupal 7_Drupal Modules_Drupal Themes - Fatal编程技术网

Drupal 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.''; $

我有一个自定义模块,可以生成一页输出,我的问题是如何向输出中添加html元素,如标题和段落等

我的模块如下

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);