Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
make an order by for vocabulary using weight field
Comment | File | Size | Author |
---|---|---|---|
#33 | 2039009-og_vocab-share-32.patch | 29.18 KB | MorinLuc0 |
#30 | 2039009-og_vocab-share-30.patch | 27.23 KB | jbylsma |
#16 | 2338089-allow-shared-vocabularies-14.patch | 693 bytes | no.exploit |
#18 | 2039009-og_vocab-share-17.patch | 25.59 KB | hefox |
#19 | 2039009-og_vocab-share-19.patch | 27.17 KB | hefox |
Comments
Comment #1
dixon_And here's a first patch. As mentioned, it's work-in-progress, but I'm marking with "needs review" just go get some feedback on if this has a chance of getting in or not ;-)
Comment #2
amitaibuI tried to avoid having multiple relationship to a single vocab, mostly because I have a feeling it's hiding some nasty scenarios.
Can you tell a bit more about your use case?
Comment #3
dixon_Yes, there are probably a few nasty scenarios you can run into. Mostly I think it comes down to access permissions and group admins being able to delete/edit shared vocabularies which will effect other groups. However, if we document these side effects properly and make this feature opt-in I think it would be valuable.
Here's our use case in more detail:
We're building a (BIG) site were people can submit classified ads for selling or buying things like cars, motorbikes, mobile phones, household items, professional services etc. etc. etc. Sort of Craig's List or Gumtree, but for the country where I currently live.
So how are we using OG and OG Vocab?
Each classified category is a term in a vocabulary. It allows our visitors to enjoy some nice faceted, "drill down" searching, it looks something like this:
As you can imagine the list of categories is always expanding and getting more granular as demand grows and new use cases emerge.
The problem we're facing is that ads under each category require a slightly different set of fields or metadata. And we don't want a separate ad content types for each category. That'd be a pain to maintain.
So, we're making each ad category into a group and using og_vocab to let each group define what additional metadata (vocabularies) that's needed for ads in that group. This lets us have one "Ad" content type with the basics (Title, Price, Description etc) and one og_vocabulary field that holds all additional metadata in a semi-structured way.
Example 1: Cars and Motorbikes will share a Transmission vocabulary (Automatic, Manual, Semi-automatic etc.) but only Cars will have a Body vocabulary (Sedan, SUV, Convertible etc).
Example 2: All property categories will share a Parking vocabulary (Covered, Garage, Street etc.) but only the residential categories will have a Available facilities vocabulary (Gym, Pool, Storage room etc.).
Comment #4
amitaibu_dixon, can you ping me on IRC?
Comment #5
charlie charles CreditAttribution: charlie charles commentedI agree, this would be a very useful feature
Comment #6
charlie charles CreditAttribution: charlie charles commentedI'm not sure if this would help
in your use case dixon
You could have look at the
https://drupal.org/project/relation
It might be help for what your
trying to achieve
Comment #7
dixon_Here's what the admin screen looks like where you can add new or attach existing vocabularies to a group.
Comment #8
paranojik CreditAttribution: paranojik commentedCould we limit the permissions on the attached (existing) vocabulary to "read-only". So that group administrators could not edit/add/remove tags on the attached vocabularies?
I also have another use case: I would like to implicitly share vocabularies between groups (e.g. child group automatically get all it's parent groups vocabularies...). Is there place for a more extensible mechanism?
Comment #9
RoySegall CreditAttribution: RoySegall commentedI think i have better idea: why not clone? We can clone vocab to other groups which the user has access to and then we avoiding any scenarios which can caused when we sharing vocabs.
Comment #10
paranojik CreditAttribution: paranojik commentedI'm afraid that's not an option. If you want to have a faceted search on those vocabularies (like dixon_ in #3 is doing) then filtering on the shared vocabulary will not work as expected...
Comment #11
no.exploit CreditAttribution: no.exploit commentedits Work find Thanks , but When u upload a image Or u make any type of ajax call or Validation field You losing value of og vocabulaire Can you help in this case ?
Comment #12
mpotter CreditAttribution: mpotter commentedI found a couple of bugs with this. When you add share a vocabulary with another group, now you can't view/edit the vocabulary as part of one of the groups. It's random which group will break as it depends on the database return order. Basically, the og_vocab_vocabulary_access() function is calling og_vocab_relation_get() which only returns a single record. If this record doesn't match the group you are in, then you get access denied.
One other problem is when removing a vocabulary from a group. In og_vocab_relation_delete() (which is another fix of the mispelled og_vocab_realtion_delete), if the $removed_vids was empty, the EntityFieldQuery at the end would fail with an error.
Now, I do hate to post big patches, but I also hate dependent patches. My main purpose in visiting this patch was to add support for og_subgroups module so children groups could inherit vocabularies of parent groups. This patch was a *great* start with that. Basically I just needed to add an option to the vocabulary to determine if it auto-adds the vocab to the children or not. The combination of og_subgroups functionality along with this patch (which lets you remove a vocab from a specific child if desired) is really powerful.
So, I present the full patch. It fixes the bugs in the #1 patch and adds the og_subgroups support. If you don't use og_subgroups you won't see any of it (it's not a hard dependency). However, in order to use the og_subgroups support, you must enable the og_vocab_allow_shared_vocabularies variable.
Comment #13
mpotter CreditAttribution: mpotter commentedA slight tweak to the patch from #12 to fix an error when creating a new vocabulary.
Comment #14
no.exploit CreditAttribution: no.exploit commentedafter i've applayed the patch "*-12.patch" still i'm getting thie error , og_vocab_relation_get() returns a single record (22) in my case
Notice: Undefined index: 22 in og_vocab_relation_get() (line 843 of /var/www/bypass/docroot/sites/all/modules/contrib/og_vocab/og_vocab.module).
can you help please , the second problem when you try to upload a image with og_vocab in the form you losing those values when this type of ajax is called
Many thanks
Comment #15
LNakamura CreditAttribution: LNakamura commentedI have a somewhat similar use case for which I opened: #2338083: Unable to see vocabularies associated with other groups after node creation. I say "somewhat similar" in that there are multiple OG vocabularies, but each is assigned to just one Group. However, a user with the appropriate role has membership to all groups and can create a post which uses any term from any of the vocabularies - so it doesn't appear to me that the vocabulary sharing described for this feature request is the same thing that I'm trying to do. Or is it? I can't tell.
I'd appreciate any insight that anyone might have to offer.
Thanks!
Lee
Comment #16
no.exploit CreditAttribution: no.exploit commentedComment #17
hefox CreditAttribution: hefox commentedHere's a signicant changed patched.
So, was looking into the fact the o#12 is using variable_set to store per vocab info, which is a nono, and came upon the realization that anyone that the vocab is shared with can completely change the vocab as far as bundles, etc. go. That's really not ideal for many use cases, so clamped down on it -- but realized there needs to be a way to say who owns the vocab and have global settings for the vocabulary, so added a new table that tracks the main vocab and settings.
Another problem is that access to edit the terms etc. was only checked on the first vocab in the table.
The major change this patch introduces is og_vocab_relation_get returns an array of relations instead of a single one. I'm debatable whether that's a good idea due to issues of api change.
Comment #18
hefox CreditAttribution: hefox commentedComment #19
hefox CreditAttribution: hefox commentedRemoving dsm and changing the shared vocab logic so can decide what og vocabs are sharable (and adding a hook to add more/change that logic)
Comment #20
hefox CreditAttribution: hefox commentedForgot to remove a check for og_subgroups when copy and pasting something.
Comment #21
hefox CreditAttribution: hefox commentedmaking it mark as shared if is already shared
Comment #22
rol CreditAttribution: rol commentedHi all, thanks for that patches although i still have a problem with subgroups...
i've this structure:
maingroup1 - og group, group type
--subgroup1 - og group, subgroup type, og group content
maingroup2 - og group, group type
--subgroup2 - og group, subgroup type, og group content
added same og field to both (sub group type, group type) -- og_group_ref_voc
shared vocbaluary = true, propagate subgroup = true
it seems everything goes well but at subgrouptype on edit form no terms of og_voc appears. ( og vocabulary only shows edit terms link on og grup content ). list of terms is empty on edit form, if i check to node/%nid/admin/taxonomy show correctly attached og vocabulary
am i missing something ? someone have same problem? thank you in advance
Comment #23
mpotter CreditAttribution: mpotter commentedUsing the patch in #21 in Open Atrium. Let's bump the test-bot
Comment #24
mpotter CreditAttribution: mpotter commentedComment #25
hefox CreditAttribution: hefox at Phase2 commentedFixing error saving when shared isn't enabled
Comment #29
Tess BakkerRemoved the 'break' that causes a PHP Fatal error with PHP7 and fixed a code style issue (one of many to go).
Comment #30
jbylsma CreditAttribution: jbylsma at Quotient commentedI've rerolled patch #25 with the diff from #29 against the current HEAD (66b7613).Sorry for the noise, hadn't realized the other had a full patch, too.Locally, the OgVocabApiTestCase and OgVocabComplexWidgetTestCase tests return the same with and without the patch. The OgVocabMenuAccessTestCase test is not completing for either.
Comment #31
MorinLuc0 CreditAttribution: MorinLuc0 as a volunteer and at Coldfront Labs Inc. commentedI added the views support to allow a view to be built off the joining table.
I have a scenario where I needed to build a view of vocabularies and terms that a user had access to across multiple groups.
But beside that this patch is great. RTBC
Comment #32
MorinLuc0 CreditAttribution: MorinLuc0 as a volunteer and at Coldfront Labs Inc. commentedComment #33
MorinLuc0 CreditAttribution: MorinLuc0 as a volunteer and at Coldfront Labs Inc. commentedIt appears I made a copy and paste error when I exported the patch, here is the updated one.