开发者

Drupal theme function not being overridden

I'm using Ubercart and I'm attempting to override the following theme function theme_address_pane() which is in uc_cart_checkout_pane.inc开发者_Python百科. So I wrote the following function in template.php:

function mytheme_address_pane($form) {
    return "asdf";
}

However, it isn't replacing anything with "asdf". What could I be doing wrong?

Edit: The devel module reports the function being called as theme_address_pane, not my overridden one.


Whenever dealing with the theming system, you often have to clear the cache to see it come to effect. Not the entire cache, just the theme registry. Here drupal stores info about which theming function and template to use. So whenever you want to change which function or template to use, you have to clear the cache.

When changing a function or template directly, clearing the cache wont be needed. Drupal wont cache the function or template, itself, but only the location/name. So you can happily alter in your theme function once you have made sure drupal has registered it.


If you put the following at the top of your template.php file (inside the php tag):

drupal_flush_all_caches();

It will clear the cache everytime the page loads. This way you won't have to flush the caches manually. However, be SURE to REMOVE it before the theme gets published, or you will see a HUGE performance hit on every page load!


To alter a theme function in Drupal 6 you need to implement hook_theme_registry_alter().

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜