Skip to main content
edited tags; edited title
Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

HOOK_MENU hook_menu() custom urlURL with argument

Source Link
Emil Orol
  • 1.8k
  • 13
  • 23

HOOK_MENU custom url with argument

I am working with a 300K records dataset and I am having some performance issues. I try creating a node for each of the records on the dataset, but even the simple path translation query is taking forever (over 50ms to execute) to get the node ID from the page and the rest of the queries on the page make it insanely slow to load a single page. The server has all the capacity it might need and it even has memcached working, PHP-FPM, NGINX, etc.

I decided to have each page coming from that dataset as simple as possible to avoid having to load all those objects and so on. The question comes when I want to use the url:

http://www.example.com/item-ABBC

ABBC is the argument that will hit the database to perform a search, but I can figure out how to accomplish this with the hook_menu:

function mymodule_menu() {
    $items['item-%'] = array(
      'page callback' => 'mymodule_abbc_view',
      'type' => MENU_CALLBACK,
    );
    return $items;
}

I am trying to avoid hitting the path table as much as possible that is why I wanted to use the MENU_CALLBACK instead of a regular menu item.

Is this possible at all?