Support export/rebuild of taxonomy vocabularies.
- Use vocabulary[module] field as a non-serial id.
- Do not support exporting taxonomy terms as they occur in potentially high numbers and there isn't a straightforward option for adding a non-serial id.
Related issue: #521630: Integrate Features with a Taxonomy Export Module.
Using the vocabulary[module] field for serial id's was yhahn's suggestion. While not strictly following the taxonomy module's intentions it may allow us to simply add module field support to Views and thus refer to vocabularies without using their serial id. Will post a link to a follow up patch to Views here later.
| Comment | File | Size | Author |
|---|---|---|---|
| #18 | 789556-18_taxonomy.patch | 7.91 KB | jmiccolis |
| #17 | 789556-17_taxonomy.patch | 7.92 KB | jmiccolis |
| #16 | 789556-15_taxonomy.patch | 6.16 KB | bcmiller0 |
| #14 | 789556-14_taxonomy.patch | 1.96 KB | bcmiller0 |
| #10 | 789556-5_taxonomy.patch | 6.06 KB | yhahn |
Comments
Comment #1
alex_b commentedDetails:
- In vocabulary[module] field, uses a prefix ("features:[machine_name]") in non-serial id. Removes "features:" prefix when showing identifier to user on web UI or on command line.
- Discovers taxonomy vocabularies as dependencies when exporting node types.
- Declares taxonomy as a feature source (for rare instances where taxonomy is used not for nodes).
Comment #2
alex_b commented#1 also applies cleanly to 1.0 beta 6.
Comment #3
alex_b commentedRelated patch for using vocabularies in Views in a Feature-friendly way: #789674: Support vocabulary[module] field
Comment #4
alex_b commentedImproved regex.
Comment #5
randallknutson commentedTried out this patch and was able to export a vocabulary into a feature and revert it on another machine. Looking good so far.
Comment #6
mani.atico commentedWouldn't this interfere with hook_term_path implementations?
Comment #7
randallknutson commentedCan you explain how?
Looks to me like hook_term_path is only giving the module a chance to change the path. If it is not provided, it will default to taxonomy/term/$tid
Comment #8
mani.atico commentedThat is the piece of code taxonomy_term_path uses to delegate path specification to modules.
To specify a custom term path you have to give the 'module' property a valid name (letters, numbers and underscopes) and use it to implement hook_term_path.
Example: if vocabulary[module] == mymodule, mymodule_term_path should be implemented if you want to override the default path for terms under this vocabulary.
In the patch, 'module' fields (inside vocabulary definitions) are written as 'features:{modified vocab name}', which is a problem since ':' character can't be use inside function names.
Comment #9
randallknutson commentedI see your point.
The : doesn't seem to be strictly necessary. It looks like it could be replaced with _ and the patch would still work. There could be namespace issues with any modules named features_{machine_name}.
Would that work?
Comment #10
yhahn commentedUpdated the patch to use
features_instead offeatures:as its vocab identifier prefix.If you've already exported vocabularies using this patch you will need to update your export to use
features_as well as run the following query against your database:Comment #11
gausarts commentedSubscribing. Thanks
Comment #12
chriscalip commentedsubscribe
note to self: dev->staging->production
only export taxonomy vocabs and the idea is to ignore taxonomy terms per no straightforward/stable solution exist
Comment #13
seanrThe patch in #10 no longer applies cleanly - first hunk fails (rest works).
Comment #14
bcmiller0 commentedseems like part of patch in #10 has already been incorporated into dev code base. This patch seems to be what is different now from current dev version.
Comment #15
bcmiller0 commentedignore me in #14, that was incorrect.
Comment #16
bcmiller0 commentedignore me in #14, that was incorrect. I think this one will run without failing.
Comment #17
jmiccolis commentedThe attached patch changes how taxonomy 'machine names' are managed. Bringing them closer inline with how they normally work. Instead of dynamically generating them I've added a machine name field on the vocab editing screen. I think this separation between the name as what we see vs. name as id is needed to prevent reckless branding changes from breaking features.
Comment #18
jmiccolis commentedSame patch as #17, minus the call-time-pass-by-reference issues.
Comment #19
jazzslider commentedJust tested this patch out (#18), and it works exactly as I had hoped. I haven't reviewed the code, but I thought it would be useful to note that it passed my quick-and-dirty "does what it's supposed to" test :)
Thanks for your hard work on this; once this functionality is incorporated into features, I'm going to put it to extensive use.
Thanks!
Adam
Comment #20
jp.stacey commentedI can confirm #18 works on a test vocabulary. It ends up with a different vid - is that right?
If so, can we move this to reviewed & tested by the community? We're itching to get moving with Features.
Comment #21
jp.stacey commentedJust a thought... is this functionality duplicated by http://drupal.org/project/features_extra ? Also see #521630: Integrate Features with a Taxonomy Export Module.
Comment #22
jmseigneur commentedI confirm that http://drupal.org/project/features_extra adds the functionality to export and import vocabularies as Features but the terms are not imported.
Comment #23
alexiswatson commentedReviewed and confirmed on Drupal 6.17, PHP 5.3. I'd say this is ready for release.
As an aside, it was mentioned by others that adding taxonomy terms would be a no-go, which does make sense for most cases. For the edge cases where a Feature depends on those terms to drive functionality, would this solution (indirectly) support any means of programmatically adding terms after the creation of a vocabulary? If so, I haven't found it - hook_install/hook_update_N is a no-go, which should have been obvious to me before, since those hooks fire before Features has a chance to work its magic. More than anything, I'm wondering if this merits its own issue - obviously it shouldn't hold up the review process here.
Comment #24
lolmaus commentedSubscribing
Comment #25
hefox commentedModules providing vocabulary features integration:
http://drupal.org/project/exportables
http://drupal.org/project/features_extra
http://drupal.org/project/taxonomy_export
Modules using hook_term_path (never used any of them, but have used hook_term_path in several projects):
http://drupal.org/project/taxonomy_redirect
http://drupal.org/project/image
http://drupal.org/project/views_tpo
http://drupal.org/project/nodeorder
Btw, exportables has a issue to export terms, it also stores it's map between ids and machine names instead of (mis)using a existing field, and provides functions for looking up them, which is quite useful for matching of exported fields with their vids, etc.
Edit: Added taxonomy_export to module list.
Comment #26
alexiswatson commented@25 - Add http://drupal.org/project/taxonomy_export (2.x-dev branch) to the list providing features integration - I was introduced to it by a coworker just after I reviewed that patch, and it looks promising.
Looking at all of the alternatives, I'm in agreement that duplicating effort is a concern, and that resolving the issue here may not necessarily be the best approach. If I understand the situation correctly, the question we should ask is "where is the best place to resolve this?" Do we want this support in Features, or another contrib module?
Comment #27
yhahn commentedIf you look at the actual integration methods you will see that the approach taken by this patch is quite different from the other listed projects. This patch adds machine names natively to vocabularies and is paired by a Views patch (and may require other contrib patches) such that vocabularies can be referenced in other configuration objects by their machine name, not their vids.
Comment #28
q0rban commentedsubscribe
Comment #29
alexiswatson commented@27 - I'm not contesting the approach (I see the merit for machine names), but with the amount of similar solutions I (and seemingly others) am just left wondering where the "definitive" one should live. :]
Comment #30
karens commentedI think it makes perfect sense for the handling of vocabularies to live in Features itself. Then other modules can build off that to do additional things, with all of them using the same foundation.
And several people have reported that it works, so changing it back to reviewed and tested.
Comment #31
Grayside commentedI'd cast my vote for favoring an external module, probably Exportables, to host the base changes that enable exportability. This allows features to be a tool, rather than an infrastructure module.
Comment #32
jmiccolis commentedI've updated the patch in #18 for recent changes in features and committed it! Thanks to everyone for your input.
@Grayside, I hear your concern, but for other non-exportables in core we do this same thing. So really this is right inline with what we're already doing and will probably keep doing until core incorporates these changes.
Comment #34
yched commentedfrom http://www.angrydonuts.com/major-new-release-of-ctools-panels-and-panels... :
Does it mean that the approach of hijacking core's {vocabularies}.module column can be reverted ?
This column has one (single ?) useful use case, defining which hook_taxonomy_term_path() hook is called to generate term paths (when you want something else than /taxonomy/term/%tid). Hijacking it can have side effects on existing code.
Comment #35
yhahn commentedNot for the time being -- just because an object is exportable using a serial ID doesn't make it useful. In particular any references in other configuration objects need to also be updated, and it's not a straightforward problem to track down every last vid reference in a view, variable, etc. and update it to be the new serial. Using the module column as the machine name for vocabs starts to address this problem.
As for
hook_taxonomy_term_path(), this hook is still usable with exported vocabularies (but under the namespace of that vocabulary's machine name) and it's unlikely to affect existing code as anyone using this hook already was purposefully altering the module field of their vocab on creation. Any vocabulary created using the taxonomy module will not be affected.Comment #36
mstef commentedI have to assume this patch is available in the aug 12 1.x-dev, right?
I don't see any difference or any support for exported vocabs in views...
Argument:
Field:
Filter:
---------------
I noticed a patch being worked on for module-name support for vocabularies in Views 3.x. Being that I'm running Views 2.x, is that my problem?
Comment #37
yhahn commentedYep, you will need #789674: Support vocabulary[module] field to reference vocabs by machine names in your views.
At least one of the earlier versions of the patches should work with Views 2.x., try http://drupal.org/node/789674#comment-3230930
Comment #38
gregglesShould the Features project page be updated to link from "Taxonomy vocabularies *" to comment #37, and also to remove the * from the description since it's now basically supported?
Comment #39
danny englanderSubscribing, interested in this.
Comment #40
smls commentedsubscribe
Comment #41
silvio commentedsubscribe
Comment #42
pbeakley commentedsubscribe
Comment #43
Niklas Fiekas commentedSubscribe.