Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By Jenechka on
Hello, I have my own module gismeteo.module and an implementing of hook theme:
/**
* Implementation of hook_theme() in gismeteo.module file
*/
function gismeteo_theme() {
$path = drupal_get_path('module', 'gismeteo') .'/theme';
require_once "./$path/theme.inc";
return array(
'gismeteo_city_list_form' => array(
'template' => 'gismeteo-city-list-form',
'file' => 'theme.inc',
'path' => $path,
'arguments' => array('form' => NULL),
),
'gismeteo_block_data' => array(
'template' => 'gismeteo',
'arguments' => array('cities' => NULL),
)
);
}
in gismeteo module directory i have a template file gismeteo.tpl.php. Help me, i cannot override it with gismeteo.tpl.php in my default theme
Comments
How are you trying to invoke
How are you trying to invoke the template, you should be using
theme('gismeteo_block_data'. ...);
<?php/** * Implementation of
Thinks to do/check a) Have
Thinks to do/check
a) Have you cleared the theme registry?
b) Does the user have the permission 'gismeteo content' (or are they user 1)?
c) Does gismeteo_block_data() return anything?
d) If you place a string in gismeteo.tpl.php does it show up?
a) Yes, many times (and
a) Yes, many times (and drupal cache too)
b) I am an admin
c) yes
d) Yes, but only if i put it in tpl file that is in my gismeteo module folder
Module works great, the problem is that drupal doesn't want to use my theme overriding gismeteo.tpl.php file.
Devel module shows:
Files used: /sites/all/modules/gismeteo/gismeteo.tpl.php
Candidate: gismeteo.tpl.php
Candidate exists, but isn't in use.
...
In your theme folder you must name it "gismeteo-block-data.tpl.php", not "gismeteo.tpl.php".
Of course, the sane thing would be for you to change
'template' => 'gismeteo'
to'template' => 'gismeteo-block-data'
as well. However, by doing this you'll lose the "element of surprise" over your enemies (enemies = the users of your module) because then they won't have any problems using and theming your module.This line serves nothing.
Oh, my god! Thank you very
Oh, my god! Thank you very much! It works. All my pains are behind now.
Helped me a lot
Thanks. The above template naming works for me too to override template from contrib module in my theme folder!!