I use the Domain Access module on my site, along with Taxonomy Menu. I've resently noticed that even though I've told it to not show empty terms, empty terms appear in the menu. I believe this is because those terms, even though they do have associated nodes, those nodes haven't been allowed to be shown on the current domain through the Domain Access settings (example below).

This should be possible to do, as I also use Faceted Search, and it's taxonomy terms only show if the associated nodes are allowed on the current domain (i.e. the correct way). So it must be possible somehow...

Example: I create a holiday node and assign it the term 'swimming'. I also specify that it appears on the domain 'watersports.com'. I setup Taxonomy Menu on all my sites and tell it not to display empty terms (so that the term 'rock climbing' won't appear, as I haven't created any nodes for it yet). I view the menu on watersports.com and see it has 'swimming' listed, but not 'rock climbing' - as expected. I then go to my other domain (extremesports.com) and find that it displays the term 'swimming' (apparently because there is a node for that term), but because that node isn't shown on this domain, when I click on 'swimming', the resulting page says 'There are currently no posts in this category'.
Note, the above is simply an example - I don't own or have anything to do with those domains :)

Hope I haven't confused you, and that this will be a useful feature for others as well.

Comments

indytechcook’s picture

I've read through the Domain Access documentation and taken a look at the code. I'm not sure how to do this yet and if it's possible.

Faceted Search only deals with displaying the terms. Taxonomy Menu save menu links to the database but doesn't handle how they are displayed in the menu. They are saved at a global level. I've reached out to the Domain Access group to see if they can lend any assistance.

indytechcook’s picture

I have updated the latest version with what the Domain Access groups says should work. Please test.

Anonymous’s picture

Ok, I upgraded to 6.x-2.1 (and had this problem: #410414: Update.php fails) but eventually got it installed ok.

I re-enabled my menus, only to find that no links are appearing in any of my taxonomy menus now... If I view the menu on the Menu > Primary Links page, I can see all the links under each menu item, bu they're all disabled. I'm assuming this is because it thinks they're empty and so doesn't show them (again, I've set the 'Hide empty terms' option).

This is true on all my domains, even those that are set to display all nodes...

indytechcook’s picture

Try out version 2.2. I committed the incorrect code for version 2.1. Version 2.2 has what I meant to put in there in the first place.

Anonymous’s picture

By the time I could get around to upgrading, version 2.3 was the latest, so I upgraded to that instead - but same problem...

indytechcook’s picture

Ok. Thanks.

indytechcook’s picture

I just made a commit that might help. Please download the dev version that will be dated after this post and retest.

Thanks again for you help.

Anonymous’s picture

Nope, still didn't work.

I uninstalled the old version completely before installing the new one. I even selected to rebuild the menu on submit, but that didn't fix it either...

For an example of what's happening, see this site: http://tlctours.info/
If you scroll down, you'll see a list of activities in the left sidebar as part of faceted search. It only shows terms that have 1 or more nodes based on the current domain. The taxonomy menu is at the top of the page in the horizontal, yellow bar. All activity terms are listed there regardless of whether or not they're empty (see 'Golf'). This is the problem.

Tim Jones Toronto’s picture

Component: Miscellaneous » Code
Category: feature » bug
Issue tags: +domain access, +taxonomy menu
StatusFileSize
new14.44 KB

Hi, I am also using the Domain Access module with Taxonomy Menu 6.x-2.x-dev and have the same problem.

I have tested Taxonomy List module and in the settings section (Count content), you can hide terms with no content. This might help with the SQL coding here?

To solve the problem, I have built an SQL View (see attached) which helps me do a simple SELECT … WHERE subdomain is the current domain name. Then I get the terms I need. The key is to display terms only where there is a connection with a node join ie. node has content and get the domain_id and/or subdomain. I hope this makes sense.

I would be happy to test any code you might be working on.

Thanks for your work!

Tim Jones

indytechcook’s picture

Status: Active » Postponed (maintainer needs more info)

Thanks Tim. The problem is that Taxonomy Menu does not control how the menu items are displayed, only how they are saved. This gives me a thought though. Can you look in the menu_links table for a menu item that does look correct and give me all of the rows on that table (I'm mainly interested in the options field).

Thanks,
Neil

Tim Jones Toronto’s picture

Status: Postponed (maintainer needs more info) » Needs review

Hi Neil,

I dont have db access to do this at the moment, but check out the following (which you can cut and paste to try).

Here is my quick suggestion:

Step 1. Get the "domain_id" of the domain visited (in my example shown below, it is number 3).
Step 2. The following SQL will get all Taxonomy Vocabs and Terms from ONLY this domain :)

SELECT

domain.domain_id,
vocabulary.name AS taxoname,
term_data.name

FROM

term_node,
node,
term_data,
domain_access,
domain,
vocabulary

WHERE

term_node.nid = node.nid AND
term_data.tid = term_node.tid AND
node.nid = domain_access.nid AND
domain.domain_id = domain_access.gid AND
vocabulary.vid = term_data.vid AND
domain.domain_id = 3

In terms of what you need to do to populate the menu at the moment, all you need to do is a minor SQL tweak (JOINs) to the data being selected in your module which would populate the menu array for each site domain?

Let me know what you think?

Cheers!
Tim

Anonymous’s picture

Any update on this?

Anonymous’s picture

Category: bug » feature
Status: Needs review » Active

I've noticed there's now a later .dev version than what I'm currently running on my site. Is it worth updating to it to see if this is fixed, or has nothing been done on this yet?

sdudenhofer’s picture

Sorry this module has changed hands. I'm not sure where indytechcook got on this. Can you go ahead and give the dev a try?

Anonymous’s picture

Updated to latest .dev version, no change. Menus still display all terms even though nodes within those terms are not displayed on that domain...

Hopefully this can be fixed soon - the two modules are basically incompatible until this is solved.

indytechcook’s picture

Sorry I didn't get to this. Life just got in the way.

Anonymous’s picture

No problem Indy :)

As I've said above, the Faceted Search module handles its taxonomy terms properly in regard to Domain Access (not displaying terms on domains that don't have matching nodes).
However, I've searched through their code for any relevant references to 'domain access' or 'domain', but couldn't find anything. The same with a search for 'permission' (in case it was simply a permission you needed to check against).

Indy also asked the maintainer of Domain Access for help with this here: #406808: Taxonomy Menu Integration

singalen’s picture

I was thinking of how to do this.

One way is to introduce a taxonomy menu "kind", which could be "regular" or "domain" (or something else, for different node access limitations).

One would need to:
* add "kind" and "kid" fields to taxonomy_menu table.
* If taxonomy menu is regular, disregard "kid". If "kind" is "domain", create a menu for each different "kid".
* Different domains would need to pull different menus, for kind="domain" and "kid"=current domain. I don't see how to effectively implement this.
* When saving taxonomy, it won't be enough to use db_rewrite_sql: it will trigger only for current domain, while we need it for each domain. Evading db_rewrite_sql feels bad, and I don't see how to effectively do it without multiplying problems.

Looks like I'll end up writing own code in order to just have domain-access-aware taxonomy menu.

indytechcook’s picture

Version: 6.x-2.x-dev » 6.x-3.x-dev

singalen, You hit the nail on the head on these points. The main issue being that Taxonomy Menu only save the menu items and does not display them.

Being that version 2 is not going to have any new features, i'm moving this to v3.

singalen’s picture

StatusFileSize
new8.15 KB

It could work if one also injected into menu module; maybe, into _menu_check_access, via access_callback field.

Anyway, I hacked a quick-n-dirty module just to evade this problem. It renders a block of a given taxonomy terms in UL-s, respecting domain (and other) access restrictions.
Someone might need this.

dstol’s picture

Status: Active » Postponed

Postponing for the time being.

Tim Jones Toronto’s picture

An update for anyone interested to run Taxonomy menu with Domain Access:

Domain Taxonomy is out for Drupal Version 7: http://drupal.org/project/domain_taxonomy

It is in early stages, but have tested working with Taxonomy menu, so each term can be assigned to a domain. Filtering of terms list for current domain is organized by processing db_rewrite_sql hook on taxonomy select queries.

Hope this helps.

dstol’s picture

Status: Postponed » Closed (won't fix)

There will be no more work on the 6.x-3.x-dev branch for the foreseeable future.