The existing methods for assigning content to a domain - by node type, by path - are useful but limited. They depend on savvy admins. Commonly, admins will want an easy way to add a node of any given type to a domain without customizing paths. It would also be useful to have a way to filter the content seen on a given domain, so only that domain's content is visible in e.g. views and node lists.
Taxonomy seems the way to go.
Here's a draft patch that adds taxonomy support to Multiple Domains. We programmatically create a vocabulary and then programmatically create a term for each domain (and update the terms when the domain name or weight changes). custom_url_rewrite() is extended to match paths based on the term. We also use hook_db_rewrite_sql() to filter node views.
This patch also includes a couple of other minor changes(a bugfix in the multidomain_domain_settings_validate() function, support for sites without clean urls) since I needed this for testing. I'll work next week to pull those into separate patches.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | multidomain-taxonomy.tar_.gz_.txt | 8.07 KB | nedjo |
| #6 | multidomain-taxonomy_3.patch | 13.85 KB | nedjo |
| #4 | multidomain-taxonomy_2.patch | 14.15 KB | nedjo |
| #2 | multidomain-taxonomy_1.patch | 8.99 KB | nedjo |
| #1 | multidomain-taxonomy_0.patch | 32.12 KB | nedjo |
Comments
Comment #1
nedjoHere's an updated patch. It's more or less working but needs refining. The update script takes care of creating a vocabulary and adding terms to it for each existing domain. Adding a node to a domain's category produces two effects:
* the node is only visible from that domain
* links to the node are to that domain.
Further thought is needed in the following areas:
1. Should this be optional or (as presently implemented) automatic on availablity of taxonomy module?
2. How should the primary domain work? Should it see all content, or only content assigned to its term? Or should this be configurable?
3. How should taxonomy interact with the two existing filter options (node type and path)? Which should take priority?
I'll continue testing and working on this. Comments and reviews meantime would be great.
Comment #2
nedjoPrevious patch wrong, here's a better version.
Comment #3
mianwo commentedGreat work!
What you are doing is just what I need, but I haven't make your patchs work on my testsite yet...
I applied multidomain-singlesignon_goto.patch, multidomain-taxonomy_1.patch, multidomain-variables-config.patch.
After patch I disabled multidomain and reenabled it, Inputed domains again. But I can't see any new taxonomy. New variables (site title, slogan, ...) are in domain config form, but changes won't save...
I don't know what's wrong, Maybe my patch order isn't correct...
Can you give me a copy of your working multidomian.module?
Comment #4
nedjoHere's a patch with a number of bugfixes and improvements.
1. Improved install and update functions for initial creation and population of a dedicated vocabulary. Fixed an error in the module name of the vocabulary created.
2. Fixed a variable name error that prevented rewriting of nodes based on term.
3.
hook_term_path()to link to the domains, which is presumably the expected behavior, rather than a taxonomy term.4.
hook_nodeapi()to remove domain term links from node view, since they aren't likely to be wanted.5. Configuration option as to the desired bahaviour on the primary/master site, either (a) see all nodes or (b) see only nodes assigned to primary site's term.
Tested and this seems to be working well.
A summary of the result:
1. A taxonomy is automatically created for domains. Each domain has a term in the vocabulary. The term names and weights are updated when a change is made to the domain name or weight.
2. On the master domain config page, admins can decide whether . The node types assigned to the domains vocabulary are also editable here.
3. Users can assign content to a given domain through regular taxonomy selects.
4. When a node is assigned to a domain's term, two things happen:
a. links to that node point to the domain it's assigned to
b. that node is only visible on lists on that domain.
5. The other ways of assigning links to a domain - by path or by node type - still work. Taxonomy only affects nodes, and only nodes of node types assigned to the domains vocabulary. So, for example, it's still possible to have all 'page' nodes assigned to 'domain1'. To do so, leave 'page' out of the domains vocabulary, and claim all 'page' content on the 'domain1' configuration page.
Is there support for this direction? Any concerns? Any particular issues we should consider before applying this?
Note:
If you've installed my previous patch and then try this one, I'm not sure what the results will be. It would be best to first clean up the site by removing the previous data. First delete the domain vocabulary and all its terms. Then here's a suggested cleanup script to run (e.g., with devel module's PHP block, or in a page with the filter set to PHP):
Comment #5
kgriffin commentedHi-
I tried to patch multiple domains with your patch, and followed all the directions I could find to do so on a windows machine with cygwin (including resaving the patch as a text file in wordpad). multidomain.info would not patch..did it manually. multidomain.module accepted most patches accept one, line 459 (moved to line 640)...did this manually. mulitdomain.install was never created, so I created it myself and cut and paste your code into it...got some really bizarre behavior once I ftp'd it up and realized that you forgot to close the .install patch with ?>...thought you might want to look into your patch and see if there other issues in your patch causing the first two problems...
Comment #6
nedjoThanks for trying the patch. Wading in and learning to apply patches is a great step to take.
Please note that the title is for the whole issue, not your followup.
There were changes made to the files since I posted the patch, here's a refreshed version, hope it works for you.
The closing PHP tag is optional and is left off by convention in Drupal.
It would be great if you could test and report back!
Comment #7
nedjoI'd like to apply this patch. I've been using it without issue on a site for some time now. Please post to this issue if you have any concerns before this is applied.
I'm attaching a patched version of the module for testing. I'm adding a .txt extension to the file so it will upload.
Comment #8
nedjoI've applied this to the DRUPAL-5 branch.
Comment #9
(not verified) commentedComment #10
fairwind@drupal.ru commentedIt's great to select domain by taxonomy! Some more wishes.
I need to show one node on cental (default) domain, and on one OR MORE additonal domains.
So i change multidomain vocabulary to allow multiselect, and select two additional domains. Yea! It's shown on selected domains and on default. But domain path of this node is rewritten to that with term with lower weight.
If i set both additional domains to one weight, then ALL nodes links to domain additional1 (included nodes than set only to domain additional2). I think it's bug.
It's better to select domain with some rules. If node assigned to taxonomy, then:
1 rule variant: domain for node selects by current domain
2 rule variant: if node can be displayed on default domain, then domain for node is default domain.
I'm not a programmer, sorry.
Comment #11
fairwind@drupal.ru commented->active
Comment #12
summit commentedHi,
I hope I state my reply on the right issue.
Should with this patch, which I presume is in the latest release available it be able to state which terms should be put on which site?
Right now the selection is pages or node-types. But I have different sites on which I would like to place only nodes from relevant terms. Is this allready possible?
greetings,
Martijn