Closed (fixed)
Project:
Display Suite
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
9 Aug 2010 at 23:26 UTC
Updated:
20 May 2011 at 01:29 UTC
I would like the ability to assign an arbitrary number of regions to each build mode and give them each a name of my choosing. Combined with #878298: Make regions and fields templatable, this would be an incredibly powerful tool. In principal it doesn't seem much different than adding fieldgroups within a region, though it would provide a higher level of organization.
Often I only use one of the regions provided by Display Suite and I've never used all five. Also, I always wish I could rename the regions I use to something more meaningful, within the context of my site.
Comments
Comment #1
swentel commentedThat would indeed be cool, but it not on the roadmap for now - we're also working hard on the port to D7 which will have this functionality by default. Not sure if this will be backported to drupal 6 afterwards since that's a lot of API changes and I really don't have time for that. So if anyone else is up for this and hands me patch and doesn't break anything between two releases, I'm happy to commit that :)
Comment #2
jstollerI'm more themer than coder, so I don't think I'll be able to help much with the patch (other than testing it). I expect to be stuck in D6 for quite some time though, so I would greatly appreciate the back-port, if at all possible.
Comment #3
zhangtaihao commentedSubscribing
Comment #4
swentel commentedCleaning up my queue and making sense of it.
Comment #5
swentel commentedThis is acutally working in the Drupal 7 version. A back port is such a big API change and needs to be in different branch, something which I'm not up to anymore - unless someone else steps up and starts coding and patching for a few weeks :)
Comment #7
donquixote commentedI think if someone wants new regions in a different layout, this should be done programmatically rather than clicketiclick.
I would be interested to see the D7 solution documented somewhere.
My own idea would be:
- either, programmatically add build modes, with custom regions. This could of course lead to name clashes with existing build modes.
- or, programmatically add build mode "patterns", each coming with its own regions and template. Each build mode can get a default pattern, and users can override the choice of pattern per node type.
Comment #8
donquixote commentedI wonder if we could have a cheap solution for D6:
1. A new function ds_layout($build_mode, $type). The return value is an array containing region names and a theme hook name.
2. Introduce a new hook_ds_layout_alter(&$layout, $build_mode, $type), that can be used to have special layouts for specific build modes.
3. Change the ds_regions() function to use the ds_layout() function. This means, ds_regions() will need the build mode and type passed as arguments.
4. Change the way that regions are rendered, so it uses the theme hook provided by ds_layout().
The bad thing is, this will be extra work to upgrade to D7 for someone who used the hook_ds_layout_alter() approach in D6.
Completely understand, seeing how much time I already spend on my own modules..
Comment #9
donquixote commentedI could work on a patch for that, but only if there is a chance of getting it in.
Comment #10
swentel commentedThere's a 6.x-2.x branch since a week or two for new features (multigroup is in, but not yet really fully tested by me). I'd be happy to commit a patch to that branch for this functionality.
Comment #11
donquixote commentedHi!
Yes, I noticed the 2.x dev branch.
Are you happy with an approach as in #8, or should I rather study the D7 branch and try a full and upwards compatible backport?
What about the upgrade path from 6.x-1.x to 6.x-2.x to 7.x-*, for custom modules and configuration ?
Atm I don't have any D7 project with a budget (= motivation) or a client or a purpose. This is why I had only a very brief look at the D7 version so far.
Comment #12
swentel commentedds_regions() is indeed the critical function, but haven't really thought about the other steps. The region/layout key could be stored into the "$module .'_display_settings_'. $object->type" variable (oh my, the more I see this, the more I hate it, D7 stores this much nicer, but anyway).
I personally don't care about the upgrade path from D6 to D7. Even just upgrading core is really hard as it is right now. Also, the DS D7 has been almost rewritten from scratch to be more flexible, has completely different (and better) storage etc. I wouldn't bother about that path :)
Need to go now, I'll try to think about this a bit more too the next couple of days.
Comment #13
donquixote commentedJust had an idea. Maybe too simple / naive.
What about
- We backport the d7 branch as "ds7.module", which can be installed in parallel with ds on D6 sites.
- One can configure a type/buildmode with ds7, to override the existing setting from ds. Otherwise, the ds setting is used. And if none of these are configured, the usual node/cck is used.
I'm not sure if this really needs a new module named ds7, or if it could be included in ds. The key is that we want old and new in parallel, so we don't damage any existing setups. (the site i work on has 38 content types..)
Comment #14
donquixote commentedWith the approach in #8, we would not store this key anywhere.
If you implement hook_ds_layout_alter(), you have to know what you are doing. The hook would be called every time that ds_regions() and thus ds_layout() is called. Maybe the result can be cached in a static var.
ds_layout() will always start with the basic default layout, and then ds_layout_alter() can decide what to do.
This means, you really need to be a module developer to take advantage of this. Unless someone codes a UI module to make this accessible to click-click site builders. This UI module would have to define its own storage.
Comment #15
swentel commentedHrm, that's right. With that approach, you can keep the initial patch size fairly small too. A static variable will be needed for sure. Maybe we should try to avoid calling drupal_alter() or module_implements() and use a variable which just has the names of the module(s) implementing that hook - I can imagine not a lot will do this. Could be even just a function (like the infamous custom_url_inbound stuff) ? Just a thought of course.
Doing a backport in soms sort of ds7 module is going to be hard tomaintain I think.
And wow, 38 content types, that's a lot :)
Comment #16
donquixote commentedmodule_implements() already has a static cache.
http://api.drupal.org/api/drupal/includes--module.inc/function/module_im....
There is also an rtbc D6 backport in the #557542: Cache module_implements() request for a persistent cache.
What I am a bit worried about is if we can safely change the signature of ds_regions().
Comment #17
swentel commentedAha, I didn't know they were trying to backport that too. Great!
As for the signature, I don't think that's a big problem.
That way, existing installations won't break.
Comment #18
donquixote commentedWe need to let modules alter both the regions and the theme hook to be used.
The alter hook would be hook_ds_layout_alter(), not hook_ds_regions_alter()
Maybe like this,
Comment #19
donquixote commentedNot sure about this one,
where is this variable configured?
Comment #20
donquixote commentedDamn..
http://drupalcontrib.org/api/drupal/contributions--ds--ds.module/functio...
called by 12 functions. These are all within ds, so no problem.
But if any other (custom) module calls ds_regions() with the old 'all' parameter, then all we can do is return the default. So these modules will not get the correct (modified) region set.
On the other hand, this is only a problem if someone wants to implement the hook_ds_layout_alter(). So I guess it is ok.
Comment #21
jstollerIf these changes work as intended, I understand I'll need to manually program the regions I want for a specific build mode, but once I do, will the UI pick up on those regions when I go to assign fields to them? Will that part still be drag and drop?
Comment #22
donquixote commentedYeah, this will be drag+drop.
What you would do in your custom module:
Then you get your two-region configuration form, and layout as in the theme function.
Comment #23
jstollerSo, would theme_myregions() displace the theme_ds_regions() function, which I am currently overriding in my theme?
Comment #24
donquixote commentedDid not really think about it, but yes, that's more or less how it would turn out.
I also considered if we should have a point in time where the entire thing is a big nested array for drupal_render(). Run it through an alter hook, then pass it to the theme function. Something like that.
But, to keep this a simple and small patch, I'd rather say no.
EDIT:
There is one difference.
The regions passed to theme_ds_regions are already sorted for print.
I think that's a bad idea: The theme function should decide itself, in which order it wants to print the regions.