在drupal中放置Html结构
您好,我已经创建了一个自定义drupal模块,在我的模块中,我必须使用while循环从数据库中获取数据,并在这个ul,li结构中打印数据。请告诉我如何才能做到这一点在drupal中放置Html结构,drupal,drupal-7,drupal-modules,drupal-views,Drupal,Drupal 7,Drupal Modules,Drupal Views,您好,我已经创建了一个自定义drupal模块,在我的模块中,我必须使用while循环从数据库中获取数据,并在这个ul,li结构中打印数据。请告诉我如何才能做到这一点 <ul class="catCol"><li><div class="itemLine"><div class="itemTitle"><a href="test_film.html"><font><font>test film</font&g
<ul class="catCol"><li><div class="itemLine"><div class="itemTitle"><a href="test_film.html"><font><font>test film</font></font></a></div><div class="itemCategory"><font><font>Pharmacy and Wholesale</font></font></div>
<div class="itemDate"><span class="date"><font><font>11 Feb 2013</font></font></span></div>
</div>
<div style="clear:both;"></div>
</li>
制药和批发
2013年2月11日
我是drupal的新手,所以如果有人能帮我解决这个问题,我会很感激的
function your_callback(){
return theme('custom_output', array('results' => $results)); // $results an array with results from database
}
function your_module_name_theme() {
return array(
'custom_output' => array(
'file' => 'your_template.tpl.php', // place your file in 'templates' folder of your module folder
'path' => drupal_get_path('module', 'your_module_name') .'/templates'
)
);
}
在“your_template.tpl.php”中,您还可以放置php和html。从数据库中选择的结果可以从模板文件的$variables['Results']variable中访问。您可以像创建模板文件一样以更简洁的方式完成此操作。有关更多信息,请参阅hook_主题。我希望几年前就看到了这个建议!这很容易成为最优雅和可维护的解决方案。