开发者

how to print output in drupal hook_block

How to Print the output, if i written in WHILE SNIPPET in the function ,

Below is my snippet, i want print retrieved result ,

i tried echo ,

but we should not use echo in drupal, and drupal set message function for debug purpose ,

So how to print my output in this example ,

function node_example_block($op='list',$delta=0){

    switch($op){
        case "list":
            $block[0]['info'] = t('THIS IS EXAMPLE NODE EXAMPLE ');
            return $block;
        case "view":    
            $block['subject'] = "THIS MY FIRST SAMPLE BLOCK";
            $block['content'] = drupal_get_form('display_node_title');

            return $block;
    }

}

function display_node_title(){

    $result = db_query("SELECT * FROM node");
    $output = '';
    while ($obj = db_fetch_object ($result)){
 开发者_如何转开发       $output .= $obj->title;
     }
    //drupal_set_message($output);
}


You're having display_node_title get passed through drupal_get_form, but display_node_title isn't a form function. If it were, it'd be constructing a $form array via the Form API and return $form; at the end.

Change:

$block['content'] = drupal_get_form('display_node_title');

to:

$block['content'] = display_node_title();

and add:

return $output;

to the end of your display_node_title() function.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜