Hi,
I'm currently working on a module that has the ability for users to upload files and reference the files in the configuration, and therefore I need the ability to have the referenced files exported when the configuration is exported.
I have put together a patch that adds said functionality by adding a new component hook (hook_features_export_assets()) which allows components to provide an array of files to be exported to [module_name]/assets/[component]/[filename].
Hope this is something that you consider as otherwise my module will not be able to provide Features export, and while it may not be something anyone else has specifically needed, there are definitely use cases where something like this is needed.
Cheers,
Deciphered.
Comment | File | Size | Author |
---|---|---|---|
#25 | features-export_additional_files-1064340-25.patch.txt | 6.38 KB | paulmartin84 |
#13 | 1064340-features-files-13.patch | 6.38 KB | hefox |
#3 | features-1064340-2.patch | 6.53 KB | Deciphered |
#2 | features-1064340.patch | 4.63 KB | Deciphered |
features-hook_features_export_assets.patch | 3.85 KB | Deciphered | |
Comments
Comment #1
Deciphered CreditAttribution: Deciphered commentedAfter discussing with hefox in IRC this morning I have some possible changes that I will look at, mainly the ability for the module invoking the hook to be more specific about the location of the file being exported.
The approaches to this that I see as being viable are:
Would create:
- [module_name]/assets/[component]/templates/file1.tpl.php
- [module_name]/assets/[component]/templates/file2.tpl.php
- [module_name]/assets/[component]/templates/node/file3.tpl.php
- [module_name]/assets/[component]/images/file2.png
- [module_name]/assets/[component]/images/example.png
Or:
- [module_name]/templates/[component]/file1.tpl.php
- [module_name]/templates/[component]/file2.tpl.php
- [module_name]/templates/[component]/node/file3.tpl.php
- [module_name]/images/[component]/file2.png
- [module_name]/images/[component]/example.png
However I do think that the second approach, while probably looking better, should probably have some restrictions on the directories. Maybe: templates, images, scripts, styles and misc?
Will look at updating the patch this afternoon.
Comment #2
Deciphered CreditAttribution: Deciphered commentedUpdated patch for above comments, went with: [module_name]/[type]/[component]/[file_destination] pattern.
Comment #3
Deciphered CreditAttribution: Deciphered commentedUpdated patch to change the hook to: hook_features_export_component_assets().
Also included includes/features.imagefield.inc to export the default image if defined.
Still need to figure out how to import the imagefield, may need a new hook.
Comment #4
hefox CreditAttribution: hefox commentedComment #5
srjoshClosing due to lack of activity.
Comment #6
hefox CreditAttribution: hefox commentedInstead of adding a new hook, modified hook_features_export_render to allow adding new additional files to export that will be copied into the feature. It's.. messy cause there wasn't the a place to put it and it's against a stable version of features cause that's how I roll sometimes.
#2292813: Store the files in the feature instead of encoded data is corresponding default content issue that this is desired for.
Comment #7
hefox CreditAttribution: hefox commentedUpdate patch to add hook so random ass files can be added outside the export render (like original ticket) and against -dev version.
Comment #8
hefox CreditAttribution: hefox commentedComment #9
hefox CreditAttribution: hefox commentedLol 2.x
Fixing syntax error
Comment #11
hefox CreditAttribution: hefox commentedComment #13
hefox CreditAttribution: hefox commentedsigh
Comment #14
ergonlogicOver in #2411869: Include file_field files in exported Features, we're working on bundling files into uuid_features-based exports. This patch will greatly simplify that work. So far, I can say that the patch applies to 7.x-2.x with only a white-space warning. I've only had the chance to test hook_features_export_files(), but it works beautifully. I'll be running it through it's paces over the next couple days and will report back any findings.
Comment #15
ergonlogicI just posted a patch over in #2411869: Include file_field files in exported Features that makes use of this patch's enhancements. It works great!
Comment #16
ergonlogicHmm, it appears to work very nicely for generating Features, but when downloading as a tarball, it renames all the included files to module_name.tar, just like the tarball itself.
Comment #17
ergonlogicuuid_features now uses this functionality to package files attached to nodes, field_collections, etc. into exported features. With the exception of the bug I mentioned in #16, this patch works beautifully. I'm going to schedule some time to fix that, but I was wondering if there's anything else that'd hold up merging this?
Comment #18
hefox CreditAttribution: hefox commentedAh, I haven't used generate tarbal in... a long time. Other then that. don't know of any issues. Having multiple reviews, if possible, would be great also
Comment #19
MatthewHager CreditAttribution: MatthewHager at Poetic Systems for Camden commentedWe've been using this patch in our platform for a while now and it works well. Would be nice if we could get this rolled into the next release.
Comment #20
mpotter CreditAttribution: mpotter commented@MatthewHager: I don't see any fixes to this to address the issue raised in #16, so I think this still needs work. Can somebody confirm whether this is working or not when downloading the feature as a tarball that contains assets?
Comment #21
paulmartin84 CreditAttribution: paulmartin84 commentedThe issue mentioned still exists, I have tracked it down to a simple typo in 1 location where it uses $filename when it should be $file_name
Comment #22
paulmartin84 CreditAttribution: paulmartin84 as a volunteer commentedAttached is a patch that fixes the issue mentioned in #16, I have also rerolled it against the latest dev.
Comment #23
paulmartin84 CreditAttribution: paulmartin84 as a volunteer commentedComment #24
attiks CreditAttribution: attiks commentedPatch looks good and works great, small nitpick
trailing white space
Comment #25
paulmartin84 CreditAttribution: paulmartin84 as a volunteer commentedTrailing white space has been removed, good spot @attiks
Comment #26
mpotter CreditAttribution: mpotter commentedCommitted (with whitespace removed) to e8a1d8d.