By ltwinner on
I have overridden the theme_breadcrumb function by using mytheme_breadcrumb() in my template.php file. However I want to move this function to a module. But when I put it in a module and changed it to mymodule_breadcrumb() it wasn't called. So how do I override theme functions from a module?
Comments
Didi you already check this guide?
Overriding themable output says:
And take a look to Beginners guide to overriding themable output too!
In short, I think the answer to your question is no... but please note that I just had a quick look to both pages!
thats just overriding theme
That is for overriding theme functions in template.php. I am looking to override theme functions in a module. How do I override theme_breadcrumb in mymodule.module?
What the docs suggest is that you cannot do it!
As I'm not a Drupal guru, I might well be mistaken.
But if you think about it, bradcrumbs (and all theme_ stuff) is a display thing, so overriding if in a theme looks like the perfect way to do it!
Yeah, there is no problem
Yeah, there is no problem overriding it in template.php. I want to override it a module though because I want to split up my code -
All the main theme functions such as page, node, comment, etc... in template.php and the rest of them in mymodule.module. It's just for usability sake.
I have just run into the
I have just run into the exact same problem again now that I am theming the pager. Does anyone here know how to override a theme function in a module?
I have a module called
I have a module called mymodule.
How do I override theme_pager in this module? I presume the function has to be registered by hook_theme()...Can someone give me a code example of how to override theme_pager in mymodule.module. Surely someone must know how to do this?
Here's what I've done and it doesn't work obviously -
I've flushed the theme registry. mymodule_pager() is not getting called, what is going wrong with this code?
You helped me! (=
You helped me! (=
Josh Utley, President & CEO
Intrepid Network Inc. | Multimedia Services & Business Solutions
"Our mission is to provide a more personable multimedia service along with the highest quality business solutions."
I don't know if you're still
I don't know if you're still interested, but here's a very useful article about this: -
http://shellmultimedia.com/articles/hookthemeregistryalter-advanced-temp...
If you implement the code in these examples, it should achieve exactly what you require. It worked for me.
I managed to do this, using
I managed to do this, using just the hook_theme instead of using the hook_theme_registry_alter. The example that follows overrides the way a term page is rendered (taxonomy/term/%):
Note: to avoid function name clashes with the original theme function from taxoniomy.pages.inc, I had to rename my theme function, and thus pass in the 'function' parameter. The 'file' parameter ensures that the file where in the function is defined is included.
After cleaning the cache registry, it worked fine.
i think your way depends on
i think your way depends on module run priorities (name, weights in the system table).. i think hook_theme_registry_alter is the proper way to replace a theme function from a module
[edit] heres the link, i knew i read this somewhere: http://www.lullabot.com/articles/overriding-theme-functions-in-modules
Fantastic!
Fantastic! Works great in Drupal 7. Finally I can remove a ton of "heavy lifting" PHP from my template.php (and easily share it among my sites and other themes). I've never been a fan of how much complex PHP tends to end up at the theme layer, often with the goal of altering Drupal's HTML output, adding classes, etc. I prefer to keep the theme layer light.
Thanks for the link :)
Theme registry alter
I managed to do this via theme_registry_alter
In your module implement the hook like this
The function should be a copy of theme_menu_local_action
Anyway I'm not able to pass "options" to MENU_LOCAL_TASK ... and I'm still finding a solution.
I know that documentation states:
but I need this behavior!