Closed (outdated)
Project:
Domain
Version:
7.x-3.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
14 Jul 2012 at 15:09 UTC
Updated:
2 May 2025 at 12:25 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
dave reidI'm guessing that this should probably store machine names rather than domain IDs as well considering the exportability of domains.
Comment #2
dave reidHere's what the initial code looks like. Seems to be working quite well already.
Screenshots:
http://i.imgur.com/GHLEP.png (single value field using the select widget)
http://i.imgur.com/JHadZ.png (multiple value field using the checkboxes widget)
http://i.imgur.com/cZX4N.png (field settings)
Comment #3
dave reidMade a domain_get_domain_options() function re-usable for FAPI #options of domains.
Comment #4
dave reidAdded a 'tokenized link or text' formatter that allows for more customization of the field output as well.
Comment #5
dave reidMarked #1587468: Show source's site name and not use redirect as a duplicate of this issue.
Comment #6
agentrickardFatal typo:
Comment #7
dave reidWhoops!
Comment #8
alan d. commentedNice approach.
I'm' not sure if I like the decoupled domain idea or not for tracking strict domain info, as there is a lot of additional logic that goes with it, like ensuring that the selected domain is part of the $entity->domains array, etc. In response to #1587468: Show source's site name and not use redirect, I actually wrote an entity based clone of domain source, but without the redirect. Ping me if anyone wants the code for this.
Comment #9
colle901 commentedI like the idea of domain reference fields, and the patch works good for me.
However, I need to apply a filter in Views to restrict the domain reference field to the current domain. The Domain Views module provides a contextual filter for the current domain, but it returns the domain id instead of the machine name. Should this mismatch be dealt with as part of this issue, or should the topic be raised in the Domain Views module issue queue?
Comment #10
agentrickardI think someone already opened a similar issue in Domain Views. Check there. If not, open a new issue that points to this one.
Comment #11
agentrickardI think this issue will suffice: #1698618: Add Domain Views filtering on term views
Comment #12
agentrickardI just re-read this patch and here are some notes:
1) It likely won't apply after other recent commits. So that needs checking.
2) It touches other functions needlessly. And, in the case of domain_machine_name_load(), breaks the function signature.
3) domain_get_domain_options() is undocumented.
Comment #13
agentrickard4) How does this work alongside #1427552: Add implementation of hook_entity_info_alter() to domain?
Comment #14
dave reidThe two issues are pretty independent.
Comment #15
stealthtech1 commentedThank you this is what i need. But i am wondering why you use the machine name as the stored value and not the domain id? The machine names can change but the id does not
Comment #16
agentrickard@stealthtech1
In a configuration / migration scenario that is actually reversed. Machine names are considered more stable.
Comment #17
nicksanta commentedPatch attached is adapted from Dave Reid's in #7, with agentrickard's feedback from #12.
Note that I have not documented domain_get_domain_options() properly. Applies properly against 7.x-3.x branch as of this morning.
Comment #18
nicksanta commentedComment #19
kingandySeems to commit fine against 7.x-3.4 too :D
Comment #20
kingandyStill commits against 7.x-3.10, though it doesn't integrate with Views filters very well - it's giving me a text entry field instead of a list of domains...
Comment #21
valentin schmid commentedPatch 17 works also flawlessly with 7.x-3.11.
Is there any chance for this patch to become integrated in the Domain Access module?
Or should this functionality be implemented in a separate module?
Comment #22
rich.3po commentedThanks for the v useful patch - also just applied to 7.x-3.11 with no problems... Except:
There is a small bug in the domain_get_domain_options() function. The line:
if (!empty($options['valid']) && empty($data['valid']) && !user_access('access inactive domains')) {should be
if (!empty($options['valid']) && empty($domain['valid']) && !user_access('access inactive domains')) {(the $data variable does not exist - presumably a typo)
Fixed patch attached
Comment #23
vadim_k commentedThanks for this patch. Works greatly with 7.x-3.11.
Please tell me how can I exclude the main domain from list in the field?
Comment #24
jsacksick commentedIs it going to be committed someday? The first patch has been sent two years ago. I need this functionality, domain_entity in contrib is doing the job but it doesn't store the machine name which is problematic as explained in #16.
This module is also adding some logic on top by implemeting the
hook_query_alter().So i'm wondering what to do? Open a new branch in domain_entity, create my own module or use this patch and add my logic on top to hide the entities?
As for #20? it's not exposed to views because it's not exposed to Entity API, in order to do that, the property_callbacks information needs to be declared, See https://www.drupal.org/node/1156554
Comment #25
jsacksick commentedFor those who need this functionality and don't want to maintain a patch, I created a sandbox https://www.drupal.org/sandbox/jsacksick/2315845
Comment #26
vadim_k commented@jsacksick
can you also include autocomplete field type? it will be very useful I think
Comment #27
jsacksick commented@vadim_k Any feature request should now be created in the issue queue of the sandbox. Feel free to provide a patch.
Comment #28
rich.3po commentedWith regards to domain_entity which was mentioned above...
https://www.drupal.org/project/domain_entity
Is this ticket just reproducing what has probably been done by that module, the latter with richer functionality?
Comment #29
jweirather commentedIs this related? https://www.drupal.org/sandbox/mathieso/1728466.
Either way, should that sandbox page include a reference back here?
Comment #30
joachim commentedIn response to #28:
The domain_entity field appears to store numeric IDs, which is not ideal. Also, while I've not investigated enough to be sure, I'm guessing that domain_entity's field type is used only to assign a domain to an entity for purposes of access. There are other use cases where you want to create a connection between an entity and a domain.
Comment #31
bluegeek9 commentedDrupal 7 in End of Life and no longer supported. We encourage you to upgrade to a supported version of Drupal. For more information, see https://www.drupal.org/upgrade.