Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By gunmajet on
Is there any way to override regular functions that don't start with 'theme_' ? I'm trying to get rid of all my hacks in the core modules to clean up my site. There are a couple functions where I just want to change an sql query. I suppose I could pretty easily make a module to replace some functionality, but for a couple lines of code, I'd rather not go through the hassle. Any ideas?
Comments
Short answer: no.
Short answer: no.
PHP doesn't play to happy with that idea. If you've gotta hack the core, the core will remain hacked.
I've done magical conditional includes before now, but I would be interested if anyone has any other insight on this.
.dan.
How to troubleshoot Drupal | http://www.coders.co.nz/
.dan. is the New Zealand Drupal Developer working on Government Web Standards
I've never messed with it, but saw this today.
http://www.php.net/manual/en/function.override-function.php
.dan.
How to troubleshoot Drupal | http://www.coders.co.nz/
.dan. is the New Zealand Drupal Developer working on Government Web Standards
Some tools available....
See this issue for some of the previous discussion: http://drupal.org/node/29428.
The tools we have available for overriding and extending include:
1. Use hook_db_rewrite_sql(). Can this help modify the queries you have in mind? (Only available if those queries are run through db_rewrite_sql().)
2. Override a menu item. Available if the function you're trying to override is called by a menu item. In a module with a higher weight than the module whose function you're overiding, redefine the menu item in a _menu hook, putting a new function (likely, a modified version of the original one) as the callback.
3. hook_form_alter.