Hello, I am the maintainer for taxonomy_menu and I had a request to integrate with domain access (#406732: Integrate with Domain Access). I took a look through your code and read through the documentation but I'm having a little trouble finding how to integrate.

Basically, taxonomy menu pulls the term information, creates a path (by calling an invoke) and creates the menu using menu_link_save. Taxonomy menu does not use hook_menu or handle any of the page call backs.

I was hoping to find hook_menu_link_alter used so I could just pull the current domain and add an option to menu_link_save but I don't think this is the case.

Please lead me in the correct direction.

Comments

agentrickard’s picture

I am not sure. DA is a node access module. So it controls node visibility. Node-based menu items are sensitive to node access rules. But your menu items are not nodes, right?

How does Taxonomy Menu interact with modules like OG? Are you correctly using db_rewrite_sql(), or do you not do any node listing queries?

indytechcook’s picture

I haven't tested OG integration yet. Good idea though.

Here is the process Taxonomy Menu goes through to save the menu link.

  1. Pull all taxonomy term for a given vocab (if updating a term or node, it only updates the menu items that have changed)
  2. Cycle through the terms and get the name, description, weight, parents, language (if I18n is enabled), etc.
  3. Pass array of information to other modules by running an invoke.
  4. Create the path for the menu item but invoking the vocabularies active path type (taxonomy menu setting)
  5. send the information to menu_link_save.

There are 2 options with in taxonomy menu that are really affected. An option to hide the menu items that have no nodes attached and other to display the number of node for that term. Both function use the same function to count the number of nodes on the term.

I have an idea how to implement this. The function that counts the term for the node would have to take in consideration what sub domain they are attached to. Since this is a per user setting, the taxonomy menu will have to rebuild it's self each time a new user logs in (different then the drupal menu rebuild).

Here is the only function that pulls node data. It just used to get a count. This is where I need to make the edit. Everything else pulls from either {term_data}, {term_node} or taxonomy menu tables.

function _taxonomy_menu_term_count($tid) {
  return db_result(db_query('SELECT COUNT(n.nid) AS c FROM {term_node} t INNER JOIN {node} n ON t.vid = n.vid WHERE n.status = 1 AND t.tid = %d', $tid));
}

Thanks for you help.

agentrickard’s picture

There's your problem. That function needs to be wrapped in db_rewrite_sql() in order to work with Node Access modules. You don't want a Domain-specific fix, just a proper implementation of the API.

function _taxonomy_menu_term_count($tid) {
  return db_result(db_query(db_rewrite_sql('SELECT COUNT(n.nid) AS c FROM {term_node} t INNER JOIN {node} n ON t.vid = n.vid WHERE n.status = 1 AND t.tid = %d', $tid)));
}

See http://api.drupal.org/api/function/db_rewrite_sql and http://api.drupal.org/api/group/node_access/6.

indytechcook’s picture

Status: Active » Fixed

Thanks alot. I'll add to the module and let you know what happens.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.