is is possible take a function that is inexplicably unthemed, like say the user login form, and make it themeable? I was thinking of implementing hook_user in my module
writing my own personal theme_* function to display the login form elements
in hook_user unsetting the existing variables and adding in my own form output.

The necessity of erasing the existing form gives me pause... is this the way to do this, or is there a more standard way?

Comments

vigo-1’s picture

Create a new block with your custom login form and disable the standard one. Just copy the code for the block out of user.module and change it to suit.

chiggsy’s picture

but on a more general level, can one just make a theme_something function, and that's it? override in template.php and away you go? or is there more restrictions than that

vigo-1’s picture

you can, but you'll have to edit the code in the module to call a theme function. Basically:
* remove the code you want to be overrideable and create a new function theme_modulename_X and pass it any variables it needs. fill the new function with the code you removed (this ensures the module will still function in other themes).
* test
* override the new theme function in your template.php file
* test
* package the lot as a .patch and submit it on the module's bug queue

dtaylor’s picture

Drupal 4.7.2

I have been trying to make taxonomy_render_nodes() in the taxonomy module themable.

I renamed taxonomy_render_nodes() to theme_taxonomy_render_nodes() and copied it to phptemplate_taxonomy_render_nodes() in the themes/mytheme/template.php file.

Any changes that I make to theme_taxonomy_render_nodes() work, but phptemplate_taxonomy_render_nodes() seems to be ignored.

If I change the name of phptemplate_taxonomy_render_nodes() back to theme_taxonomy_render_nodes(), I get the error message pointing out that I have defined the same function twice. If I introduce a syntax error in phptemplate_taxonomy_render_nodes(), I also get a complaint.

I have had better luck with other functions; phptemplate_product_view_collection() for the ecommerce product module, for example. These functions were already defined as theme_modname_function(), though.

Am I missing something basic, or is there something that says "Hey dummy, don't try to theme this taxonomy function?"

Thanks

dtaylor’s picture

When changing the calls to the newly themeable function, I had changed the call from modulename_function() to theme_modulename_function().
I forgot that, at least for Drupal 4.7, it should be theme('modulename_function' <, parameters>).
So I changed the call from theme_taxonomy_render_nodes($selected) to theme('taxonomy_render_nodes', $selected) and it worked great.

wilmegape’s picture

Thanks for the explanation, this gives me the needed flexiblity in theming the taxonomy term page, hope it will be included in the future version.