[support] HTML helper function in Drupal

Davide Michel 'ZioBudda' Morelli michel at ziobudda.net
Thu Feb 21 08:48:01 UTC 2008


Bojan Mihelac ha scritto:
> On 20.2.2008, at 18:26, Earnie Boyd wrote:
>
>   
>> Quoting Bojan Mihelac <bmihelac at 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.

-- 
Michel 'ZioBudda' Morelli                       michel at ziobudda.net
Consulenza sistemistica in ambito OpenSource.
Sviluppo applicazioni web dinamiche (LAMP+Ajax)
Telefono: 0200619074
Telefono Cell: +39-3939890025 --  Fax: +39-0291390660

http://www.ziobudda.net                         ICQ: 58351764  
http://www.ziobuddalabs.it                      Skype: zio_budda
http://www.ajaxblog.it        			MSN: michel at ziobuddalabs.it                   
						JABBER: michel at gmail.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20080221/157d71b0/attachment.htm 


More information about the support mailing list