开发者

Drupal theme function is not called?

I am new to Drupal and trying to create a theme function that create a little iframe for my videos. I am calling the function in my menu callback function. The problem is that the theme function is not called. I tried to append the module name at the beginning of the theme function and also removed and 开发者_运维知识库it didn't help. I clear the cache every time I make changes and enabled the backtrace in my devel module and I see the following warning:

warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'mymodule_mobile_mymodue_mobile_build_iframe' not found or invalid function name in call_user_func_array() (line 656 of /var/www/includes/theme.inc). =>

function my_callback_function(){
$output = theme('mymodule_mobile_build_iframe',array(
           'arg1'=> $stream,
           'arg2'=> $node->nid,)
               );
return $output

}
function mymodule_mobile_theme(){

      return array(
        'mymodule_mobile_build_iframe' => array(
        'arguments'    => array(
        'arg1'    => NULL,
        'arg2'   => NULL,),),);
}

function theme_mymodule_mobile_build_iframe($arg1,$arg2){

    $host = 'http://www.myhost.com';

    $output = '<video width="320" height="240" controls="controls"> <source src=
        "'.$host.'/'.$arg1.'/'.$arg2.'/playlist.m3u8" type="video/mp4" />
        Your browser does not support the video tag.
        </video>';

    return $output;
}

Thank you all in advance!


I would suspect this is a simple naming problem; is your module called mymodule or mymodule_mobile? This will be the same name as your module's .info file (obviously minus the .info).

If it's called mymodule then you just need to change your theme hook to be named mymodule_theme(). All Drupal hooks are MODULENAME_HOOKNAME(), if your module is called mymodule Drupal will be expecting to look for a theme hook function called mymodule_theme().

The simplest test is to put the line drupal_set_message('test'); as the first line of your theme hook function and clear your caches. If you don't see the test message output to the screen, your hook function hasn't run, and it isn't named correctly.

If you do see the test message and it still doesn't work I'd suggest it indicates a problem somewhere else, the rest of your code looks spot on.

EDIT I just noticed in a comment you're using a template file...I think there's some confusion as to do so you'd need to have the template key in the array returned from hook_theme(). Could you just clarify that?


i don't see any problem in ur code (i didn't test it) , but are you sure you have cleared the cache...please clear the cache and tell me if this problem is still exist

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜