Reputation: 394
Hi I have created a custom drupal module and in my module I have to fetch data from database using while loop and print the data within this ul,li structure.Please let me know how could I do so
<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>
I am new in drupal so if anyone could help me with this issue it would be appreciable.
Upvotes: 0
Views: 68
Reputation: 467
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'
)
);
}
In your 'your_template.tpl.php' you will be able to put php and html as well. Results selected from database are reachable from your template file in $variables['results'] variable.
Upvotes: 2