1

The core Path module defines the page admin/config/search/path which gives a listing of all path aliases.

The menu hook in the module calls the path_admin_overview function in path.admin.inc which makes the query to retrieve a list of URL aliases:

$query->condition('alias', '%' . preg_replace('!\*+!', '%', $keys) . '%', 'LIKE');

What I would like to do is somehow intercept this query and modify the condition in a custom module (to avoid hacking core, of course). To be more precise, I want to make it possible to extend the condition to search the source column as well as the alias column as indicated above.

My first thought was to intercept the Path admin listing form: path_admin_filter_form which I have done using hook_form_alter. I was then hoping that somehow I could override the existing submit handler or attach an second one which would call path_admin_overview, but of course I cannot directly modify that core function.

So it seems like I would have to make my own custom copy of path_admin_overview and modify the code inside, then have that called instead. Of course this doesn't feel right either - since if the Path module changes, the module will fall behind.

Is there some kind of hook or pattern I can employ here to modify the query in path_admin_overview or otherwise achieve the goal indicated in bold in a standalone module?

EDIT: It looks like it could be possible if the query in path_admin_overview was tagged (it isn't currently), see here: https://www.drupal.org/node/310077#hook_query_alter

  • Have you tried the tag and hook_query_alter apporach? I think it might works, I was about to answer that until I saw your edit. – sanzante Nov 30 '15 at 12:03
  • Alas, there is no tag for this query. I will see if I can request it - but I'm still open to other approaches for solving the goal in bold if you have any ideas! – njp Nov 30 '15 at 12:15
  • Yes, you're right, query must have a tag or you can't get it on that hook. – sanzante Nov 30 '15 at 12:18
2
+50

You can override admin/config/search/path path using hook_menu_alter and use a custom function as menu callback.

function oyurmodule_menu_alter(&$items) {
  $items['admin/config/search/path']['page callback'] = 'mymodule_custom_path_admin_overview'; 
}

Then your mymodule_custom_path_admin_overview shoud be a copy of path_admin_overview with your needed alterations.

This is not optimal as you should keep your function code in sync with original code, so any patches applied to path_admin_overviewfunction should applied to your altered function, but is the only way you can alter the functionality without hacking core.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.