Domanda

Having some module, defined some url in hook_menu() and need to display there some theme (modules/mymodule/templates/mytheme.tpl.php). How do I show mytheme.tpl.php content on needed url?

function mymodule_menu(){
    $item = array();

    $item['somemenu'] = array(
     'page callback' => 'somemenu_display',
  );

    return $item;
}

function somemenu_display(){
       return WHAT_IS_THIS_FUNCTION('modules/mymodule/templates/mytheme.tpl.php');
}

And it will be good to display only these contents, without and header/footer.

È stato utile?

Soluzione

The function is Theme()

return theme('some_theme_function_template', array('aValues' => $someArray));

You then need to use the theme hook like this:

function my_module_name_theme() {
    return array(
        'some_theme_function_template' => array(
            'template' => 'mytheme',
        ),
    );
}

It now searches for mytheme.tpl.php in the root of your module.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top