Closed (won't fix)
Project:
Features
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
14 Mar 2009 at 16:51 UTC
Updated:
23 Aug 2012 at 14:18 UTC
Jump to comment: Most recent file
Comments
Comment #1
yhahn commentedY, this is part of a larger issue of trying to capture variable settings in a reasonable way...
The workflow settings should be straightforward but node type variables tacked on through form_alter() might need some more forensic science / backwards-engineering.
Comment #2
rszrama commentedIf it helps, you can simply manually fire off the form preparation... I did this for some code in Ubercart where I wanted to display a summary of a form that took alterations into consideration:
The
$formarray would contain any form altered elements after this. Then you can iterate through the form structure to find all the variables. Still not an easy task for sure. : DComment #3
jon pughHere's a patch that adds the Node Type Variables to the Node Export function, as well as adds $type->help, min_word_count which were missing.
I think I came up with a reliable solution to the Node Type Variable problem: Do it the way core does it.
As you can see from http://api.drupal.org/api/function/node_type_form_submit/6 , The Node Type edit form grabs every Core nodetype field, then "whatever's left is assumed to be a persistent variable.". After which it calls variable_set() on each additional form_value, the name being the key of the $form_state['values'] array item plus $node->type appended to it!
So, this simply adds an additional item to the hook_default_types array: variables.
Reverting is just looping through $node_type->variables and calling variable_set();
It works Swimmingly. Change the comments settings, and The "Overridden" flag is set.
so you end up with exported code like this:
Comment #4
yhahn commentedI'm not happy about abusing
hook_node_info()with information that it's not supposed to contain. In addition, I've found that in practice node type variables need a bit more micromanagement than features' automated code exporting can provide -- there are some content type variable values that you want to export while others you may want to omit because you had them set specifically for your use case but may not be appropriate for a general-purpose feature.If this functionality is important to your needs, you may want to split it out into its own hook (
hook_node_default_settings or so?) and add features integration for it in its own module or include.Comment #5
jon pughYeah, that makes sense. I'll look into creating up a hook for that... I also had an idea of how to incorporate variables in a feature beyond hook_strongarm(), so that changes to system settings forms can be made, updated, or reverted.
I think I'll look into integrating the nodetype settings into that instead.
There were two node settings that are a part of core that still need to be added to features.node.inc, 'help' and 'min_word_count'.
I'll re-roll a patch for that if you'd like.
Thanks!
Comment #6
that0n3guy commentedsubscribing
Comment #7
derhasi commentedI attached a small patch that will "only" add
helpandmin_word_count. As it is a core setting this should be implemented in features.It is diffed against the current BETA3.
Comment #8
derhasi commentedComment #9
rszrama commentedI'd like to see this expanded to include the setting from the theme global settings page to display the "posted by" information for the node type as well... it's another core setting that would be excellent to preserve in Features.
Comment #10
derhasi commentedIs there any reason why to not use/implement cck's content_copy import/export functionality for node type settings?
( http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/cck/modules... )
Comment #11
moshe weitzman commented@careernerd - did you ever share a new module or include for comment settings, fivestar, workflow, etc?
Comment #12
yhahn commentedI've committed derhasi's patch in #7 (http://drupal.org/cvs?commit=269174).
As for the larger issue of managing content type settings stored as variables I think an ideal implementation would leverage a more generalized variable override/management API (e.g. something like strongarm) even if it implements variable export only for the subset of variables exposed on the content type form.
It's also worth recognizing that certain variables store node-type related settings in a non-granular/module fashion (e.g. an array like
array('blog' => 1, 'book' => 0, ...)) that would require additional management to split up across features. Thetheme_settingsvariable (which stores post display information per node type) is an example of this.Comment #13
jon pughSo do you think we should move the Variable defaults/override functionality to features.module itself? Let me know, I'm going to tackle this soon.
Strongarm is good in concept, but I think it should allow modification of variables with a warning and overridden flag, just like nodes, fields, and views work now.
As for the non-granular settings, I see the problem... If we're gonna have any kind of generic variable defaults system I'd have to say all we can do is document this problem and try to let feature-builders and module devs know that these settings types pose a problem. If certain modules that are useful enough have variables like this, we can try to patch them so that they store the vars the better way.
Comment #14
yhahn commented@careernerd: It would be great if you could look at the existing strongarm "override" mode implementation (you can put strongarm in this mode on
admin/settings/strongarm) and see if it makes sense to expand off of that.Another issue that was brought up is that variable exports truly pollute the info files of features. I wonder if it makes sense for there to be an intermediate structure, say a "variable set" that allows you to define bundles of variables and their default values and export those together with a single ID?
Comment #15
damienmckennaSo, given that hook_node_info() in D6 is not sufficient for managing content types because it does not allow for integration with other modules, could content type creation just be handled through an install script -type process that executes the CCK APIs directly?
Comment #16
boztek commentedsubscribing
Comment #17
damienmckennaThere are a good deal of content type settings that are *not* just variables; given that CCK bundles Content_Copy and thus gives everyone a simple way of importing & exporting content types, I don't see any reason why this would not be used? I'll dig into it.
Comment #18
damienmckennaRelated to this, should the hook_node_info() set the content types to be locked?
Digging through the D6 code.. the node types are compiled in node_types_rebuild() which:
As you can see above, hook_node_info() passes along everything that is loaded right through to the final hook_node_type().
This means that it is perfectly OK to load up hook_node_info() with whatever additional data we want to use. :-)
Comment #19
damienmckennaTo continue the brainstorming some more...
What we could do is:
This would be a cleaner way than just arbitrarily storing everything as a variable and also not only rely upon the existing hook_node_type() functionality but also extend it slightly by adding the 'features_module' value so modules can react accordingly.
Thoughts?
Comment #20
damienmckennaHere's a new hook to allow other modules to extend the data added to hook_node_info() to match some of my thoughts above, API documentation provided; FYI I also added a new function features_export_render_array() which is used to simplify the logic in the main node_features_export_render() function.
Here's the hook documentation for your edification:
Any feedback?
Comment #21
damienmckennaFYI the patch is untested :o)
Comment #22
damienmckennaSmall fix to the patch, it wasn't closing the original node_info arrays.
Comment #23
todd nienkerk commentedIf this is at all helpful, my workaround is to add a
.installfile to the features module directly that implements ahook_install()and changes variables usingvariable_set()Comment #24
damienmckennaFYI I'm moving my patch over to CCK itself: #726330: Rewrite content_copy module to use existing hooks
Comment #25
yhahn commentedSee http://drupal.org/project/content_type_exporter
Comment #26
tom_o_t commentedWould you mind providing a reason why this was marked as won't fix? The project linked to in #25 is marked as obsolete:
Comment #27
alfthecat commentedHi,
I'm not actually sure if my issue is related at all, but I believe so.
I run features in an installation profile. It all works great except the fact that the nodes are not sporting the correct 'promoted to frontpage' settings and they don't get the correct menu entries.
Everything I export with my features works great, it just seems as if Drupal's default way of dealing with certain settings refuse to budge for what my features are instructing. I can not revert and two features always appear as overridden, from the first time my installation profile completes.
I have looked to the issues about not being able to revert, I just suspect my problem is somewhere else. I just want to have my features take care of all the settings I export through them, including Drupal's defaults.
Comment #28
Shadlington commentedSubbing
Comment #29
mpotter commentedClosing this for lack of activity. Please re-open this issue if you can reproduce it in the latest version.