Theme overrides don't override modules.tpl template

drew reece - June 22, 2009 - 20:06
Project:Google Groups
Version:6.x-2.0-beta2
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

I have copied this modules block template (google-groups-subscribe-form-block.tpl.php) to my theme & also copied the core block.tpl into my theme. I cleared the caches but still the module template is used to theme the block.

How can I override it? My theme is a subtheme of Blueprint theme, but I also added the google-groups-subscribe-form-block.tpl.php to Acquia Slate theme & it didn't override either. Do I need a specific preprocess function?

Devel module states the the modules tpl.php is used to theme the block.

#1

dragonwize - June 22, 2009 - 21:37
Status:active» postponed (maintainer needs more info)

It works through the normal theme system the same as all other templates.

Ensure you are not changing the file name and that you are clearing your theme registry.

Beyond that I would need more information about exactly what you are trying to do, what you are expecting, and what you are actually getting in your output.

#2

drew reece - June 23, 2009 - 20:06

I want to add classes to the markup of the subscribe block.

So I copied the file sites/all/modules/google_groups/google-groups-subscribe-form-block.tpl.php to sites/all/themes/customtheme/google-groups-subscribe-form-block.tpl.php.
I added block.tpl.php to my theme from /modules/system/block.tpl.php to sites/all/themes/customtheme/block.tpl.php.
I added changes to the google-groups-subscribe-form-block.tpl.php in my theme.

I used devel to clear all caches, - no text appeared, theme developer says the block is themed from the module - (see attached screenshot).

My theme is a subtheme of Blueprint, so I added my changed google-groups-subscribe-form-block.tpl.php to that theme & it still will not show up in the block output.

I have cleared the caches between the changes. As mentioned I also tried to use the changed google-groups-subscribe-form-block.tpl.php in the Acquia slate theme but it still failed to alter the html of the subscribe block.

I'm using Drupal 6.12 with 6.x-10 of Google Groups.

EDIT
I forgot to mention, other overrides work from my custom theme, such as node-event.tpl.php overrides my event nodes and block-user.tpl.php overrides the main navigation block.

AttachmentSize
Picture 7.png 41.58 KB

#3

drew reece - June 28, 2009 - 13:15

Well here is some more info from the status page…

Drupal 6.12
File system Writable (public download method)
GD library bundled (2.0.34 compatible)
GD library bundled (2.0.34 compatible)
MySQL database 5.0.67
PHP 5.2.6
PHP memory limit 256M
PHP register globals Disabled
Unicode library PHP Mbstring Extension
Web server Apache/2.2.9 (Unix) mod_ssl/2.2.9 OpenSSL/0.9.7l DAV/2 PHP/5.2.6
jQuery Update 1.2.6

I really don't know why this fails for me, any ideas?

#4

dragonwize - June 30, 2009 - 21:24

I am not sure why it is not working for you. I don't have much time to debug right now. I would suggest upgrading to 2.0 and see if that fixes it for you. There are many bug fixes in that release and 1.0 will soon be completely unsupported.

Even though 2.0 says beta right now, it is stable. It really should be marked RC as I was just letting it sit there long enough for people to test it out and report back. It looks like there are close to 30 sites using it now without issues reported so it will be marked stable as soon as I get around to that soon.

#5

ryan_courtnage - September 25, 2009 - 18:55

@drew reece
Did you ever figure this out? I'm having the *exact* same problem, but with a different module (I am not using google_groups.module).

#6

drew reece - September 26, 2009 - 20:00

No I haven't figured this one out, sorry.
Are you using the Blueprint theme too?

#7

ryan_courtnage - September 26, 2009 - 20:17

Hey Drew,
No, in my case, I can duplicated the problem regardless of the theme I'm using.
Cheers
Ryan

#8

ryan_courtnage - October 16, 2009 - 20:40

Drew,

So I figured out what the issue is. Have a look at my comment here:
http://api.drupal.org/api/function/hook_theme/6#comment-158

Ryan

#9

ryan_courtnage - October 16, 2009 - 20:43

I should mention that the solution also applies to google_groups.module, as the theme hook name does not match the template name:

<?php
/**
* Implementation of hook_theme()
*/
function google_groups_theme() {
  return array(
   
'google_groups_block0_content' => array(
     
'template' => 'google-groups-subscribe-form-block',
     
'arguments' => array(),
    ),
  );
}
?>

#10

drew reece - October 16, 2009 - 23:43

If I understand you correctly Ryan, a fix would be…

changing line 118 of google_groups.module from

<?php
/**
* Implementation of hook_theme()
*/
function google_groups_theme() {
  return array(
   
'google_groups_block0_content' => array(
     
'template' => 'google-groups-subscribe-form-block',
     
'arguments' => array(),
    ),
  );
}
?>

…to this…
<?php
/**
* Implementation of hook_theme()
*/
function google_groups_theme() {
  return array(
   
'google_groups_subscribe_form_block' => array(
     
'template' => 'google-groups-subscribe-form-block',
     
'arguments' => array(),
    ),
  );
}
?>

Is that what you mean? I tried altering it in the module to see if it would pick up the the google-groups-subscribe-form-block.tpl.php in my theme but it didn't seem to work. I expect there are other things I need to change.

I think you logic is correct because I can now override the google-groups-subscribe-form-block by adding a 'google-groups-block0-content.tpl.php' to my theme. I don't think that is the correct way to do the override.

Thanks for looking into this,
Drew

#11

dragonwize - October 17, 2009 - 06:32
Version:6.x-1.0» 6.x-2.0-beta2
Category:support request» bug report
Status:postponed (maintainer needs more info)» fixed

Thanks ryan_courtnage. Change committed.

#12

drew reece - October 18, 2009 - 19:02

I updated to the 6.x-2.0 version and it fixed the issue.

Thank you ryan_courtnage and dragonwise.

#13

System Message - November 1, 2009 - 19:10
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.