I want to define additional regions. Right now it looks like the only way to do this to change nodeformcols_form_regions() directly. It would be nicer if this could be done as a hook, perhaps even taking node type into account, so that external modules could specify additional regions for theming the node form.
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | nodeformcols_6.x-1.7_525786.13.patch | 5.89 KB | twod |
| #13 | nodeformcols_525786.13.patch | 5.51 KB | twod |
Comments
Comment #1
Hugo Wetterberg commentedThat's a great feature request. Will do.
Comment #2
jonathan_hunt commentedI'm just about to introduce some regions in the pattern [node_type]_header, [node_type]_payment etc. for some CCK-based forms. If you come up with some code, I'm happy to test a patch, or I might get around to writing a patch next week.
Comment #3
jonathan_hunt commentedFYI, I have some code like the following:
i.e. pass content type to region definition and if a hook exists, retrieve region definitions from the hook.
Similarly, since each content type can define it's own regions, it also needs to define its own default placements.
This isn't quite ideal as if there is no common region between two node types the fields don't show up in the Manage Form list of fields by region.
Perhaps the set of regions returned from the content type need to be merged with the base set defined by nodeformcols?
Comment #4
Hugo Wetterberg commentedYep, but this will have to be done with a alter instead I think.
Along the lines of:
That way extenders can implement:
Comment #5
jonathan_hunt commentedAgreed, drupal_alter() is a more appropriate solution.
So in nodeformcols.module, I have:
and in template_preprocess_node_form(), pass type:
Also, in nodeformcols.admin.inc, pass type
The main sticking point is how to pass $type into the context for nodeformcols-configuration.tpl.php? That's not something I've done before...
Comment #6
Matt-H commentedI am very interested in this modification to the node form column module. Is this likely to be included in the next release, and might a new release forthcoming? (Alternately, a patch may suffice for my needs, which I may create using Hugo and Jonathan's code.) Thanks.
Comment #7
castawaybcn commentedsubscribing
Comment #8
jvieille commentedSubscribing
Comment #9
Matt-H commentedThe missing piece, how to pass $type into the context for nodeformcols-configuration.tpl.php, is to add a preprocess function for the tpl.php. From there, we can get the content type from the fourth argument being passed in.
(The url version of the content type uses hyphens, but the machine readable version uses underscores.)
This also means that the $regions variable should no longer be called from the tpl.php file.
You will also want to be sure to pass the content type to _nodeformscols_default_field_placements() in nodeformscols.module.
And the should about do it!
Comment #10
Matt-H commentedI've rolled all of these changes into a single patch. I'm changing the version to 6.x-1.6, since that is what the patch was built against.
I've also included in the patch a nodeformcols.api.php file, to document the various hook functions in the module.
I've also added some basic caching into the nodeformcols_form_regions() and _nodeformscols_default_field_placements() functions, so the hooks don't need to be called multiple times.
Comment #11
davidburnsI've applied these changes to D7 version. Here's a patch.
I'm not sure if nodeformcols_preprocess_nodeformcols_configuration is ever being called or even the nodeformcols-configuration.tpl.php. So this patch may still need some work
Comment #12
davidburnsHere's the correct diff without my features module diff at the bottom
Comment #13
twodRerolled for 7.x-1.x and 6.x-1.7 (Only tested the D6 version since that's what I currently use it on.)
Moved the default placements hook invocation so it only overrides defaults and not the actual placements set in the GUI.
Removed the template preprocess hook implementation and made the template read the available regions from
$element['nodeformcols_form_regions']instead. I already had it working this way in a private version of the patch so I just kept it instead of adding the preprocess hook implementation. Minor benefit; no need to clear cache after applying the cache. ;)Completely remove the
$has_elementsvariable since it is no longer used in the previous patch. Changed the string to '#has_elements' instead of 'has_elements' since Drupal would otherwise interpret that property as a child element.Comment #14
jgtrescazes commentedHello,
I Just tested #13 patch on 7.x-dev and it works as expected.