Bojan Mihelac ha scritto:
On 20.2.2008, at 18:26, Earnie Boyd wrote:
Quoting Bojan Mihelac bmihelac@gmail.com:
Hi all, does Drupal have some helper function for creating HTML tags, like it exists in Rails (and I think cakePHP)?
somethin that could be called like this:
$output = tag("h1", $node->title, array('class' => ''title));
You mean something like http://api.drupal.org/api/function/theme
Earnie, thanks for your answer.
Well, I was looking for some easy way to create HTML code from custom module. I would like to be able to call template file and send some variables to it for styling. Something like: $output = template("my_template_name", $vars_to_pass). Is there function for this?
Like this:
function _mw_blog() { //Prendo l'ultimo blog //echo "èèèèèè"; //print_r("pippo"); $query = "select nid from {node} where type = 'blog_programmazione' and status = 1 and promote = 1 order by nid desc limit 0,1"; $nid = db_result(db_query($query)); $node = node_load($nid); //dvr($node); $var = array(); $var['title'] = $node->title; $var['body'] = $node->teaser; $var['link'] = "/".$node->path; $var['image'] = "/".$node->field_forum_img[0]['filepath']; //dvr($var); return _phptemplate_callback('blog-front',$var); }
blog-front.tpl.php:
<div class="hpBox2">
<H3>Dal Blog</H3> <div class="mid"> <img src="<?php echo $image ?>" width="90" height="65"/> <p class="titolinoBox"><?php echo $title ?></p> <p><?php echo $body ?></p> <p class="boxLink"><a href="<?php echo $link ?>">Leggi l'articolo</a></p> </div> <div class="fine"></div> </div>
M.