User login

Override a theme function with a module

You cannot override a themename_ prefixed function in the theme itself. Nor a in the template, prefixed with phptemplate_

But for a function defined in a module only as theme_function_name, read on:

overwrite a theme function in a module
err, override a theme function in a module

No one answered him:

Is there a way to override a theme function created by a module in another module?

I know how to override theme functions with a phpTemplate theme.
But I would like to do it from another module (that will be put in contrib).

Is it possible?



Using Theme Override Functions

Well, it's not the best way, because you can't guarantee people are using phptemplate (although they really, really should be!) you can override from a module with phptemplate_name_of_theming_function()


Possible solution

Try to use hook_theme in your module declaration file.
For example if you implement the module test then u can override the theme by using inline_theme().

In this function you can return an array with the theme declaration like:

return array('test_test' => array('arguments' => array(...), 'file' => ''));

with as the theme declaration.

theme overriding in another module

this will help to override theme function in another module.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.