Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
I want to propose an integration with the context module, which permit to connect conditions (eg. path is user/*) with reaction (eg. set a menu item for active handler)
This could be useful in ds layouts with blocks that need contestualization but either for conditional layouts.
Thanks in advance.
Comment | File | Size | Author |
---|---|---|---|
#4 | ds_context.patch | 516 bytes | muka |
#4 | ds_context.zip | 2.99 KB | muka |
Comments
Comment #1
swentel CreditAttribution: swentel commentedAlways interested ! :)
Comment #2
netsensei CreditAttribution: netsensei commentedI did something similar for Views already: http://drupal.org/project/vcd
It's a cool feature, but I would suggest waiting for a unified context API in D8. Currently, there are different options: context, rules,... each with their own dependencies. If anything, if you hook context, you might as well support rules too if you want to leave people a choice.
Comment #3
muka CreditAttribution: muka commentedThank you, this is a good example. I'll study a bit more your module.
Comment #4
muka CreditAttribution: muka commentedI'm back!
Attached a proposal for a ds_context module (many thanks to netsensei for the hint).
Actually offer both a condition and a reaction called "Display suite: fields visibility".
- The reaction hide/shows the field based on conditions.
- The condition set a "default state" for selected fields (in this case the above reaction should be chosen) eg. set some fields always hidden
In this way a field can be always hidden with the exception of another condition "overriding" the default eg.
show some fields only in this menu trail.
Comment #5
swentel CreditAttribution: swentel commentedAlso, I think it might be better to use hook_entity_view_alter - or the field_attach_view_alter - that way *all* fields could benefit from the context and there's no patch needed for ds.module itself, because at this point, I think the only thing context can work on are ds fields and not field api fields, right ?
Comment #6
muka CreditAttribution: muka commentedActually the reaction get entities with entity_get_info() and list the fields in entity->bundle->layout->settings.
The field api items are missing... still needs work :) I'll try to fix them soon.
I post some additional ideas:
- ds code support (condition/reaction)
- passing arguments to field (eg. block views) from a view result or ds code (as reaction)
- custom theming / layout switcher (reaction)
- hide / show a layout region
Use cases:
- node has term, display related nodes with term
- user has this role, display a layout-[$user->rid] layout
- user is going to buy a product, show the region with the related products he could be interested (based on cart or tracker as nid view arguments).
Comment #7
swentel CreditAttribution: swentel commentedI wonder if this shouldn't be a separate project for a few reasons:
So I think I'd rather see someone else taking this up as a separate project on d.o so I can concentrate on DS core (+ contrib support that I/we at work use a lot). Muka, You are absolutely free to start such a project and maintain it yourself if you like :) Let me know what you think, because I'm pretty close to setting this one to won't fix for the reasons outlined above.
Comment #8
muka CreditAttribution: muka commentedYes, make sense. This is a related module and won't help a lot on the growing of ds core.
Let's close it. Thanks
Comment #9
swentel CreditAttribution: swentel commentedI've taken this to http://groups.drupal.org/node/167684 for further discussion.
Comment #10
yannickooI showed swentel that changing the view mode is possible via hook_entity_view_alter. For example when you want to force all entities to use the teaser view mode you just would write:
So to implement the context integration we need some hooks, let's take a look at the context.api.php file.
Also a good example is the nd_context_bm module. It has a plugins directory where the condition and the reaction is and the hook stuff is located in the nd_context_bm.module.
I think the necessary hooks are:
I will take a look at this later.
Comment #11
swentel CreditAttribution: swentel commenteddrupal.org/project/ds_context will be available soon :)
Comment #12
dman CreditAttribution: dman commentedBump? We are looking for ds_context today. Is it still sandboxed?
Looks like it shouldn't be TOO hard (if x then use this alternative view mode to render the node) but if there is prior art, I'd like to go from there.
Searching not working for me yet.
Comment #13
attiks CreditAttribution: attiks commented@yannickoo do you already have some code?
Comment #14
yannickooI'm so sorry, I deleted that module for 1 month when cleaning my machine. This has nothing to do with Display Suite because it is for entities which are independent from Display Suite.
When I have some time I will try to recreate a context_view_mode module, okay?
Comment #15
attiks CreditAttribution: attiks commented#14 no problem, it looks interesting so I was just wondering. Take your time ;-)
Comment #16
yannickooFYI still have this on my todo list!
Comment #17
jpstrikesback CreditAttribution: jpstrikesback commentedYannicko FTW!!!
Comment #18
yannickooI thought that we create a new module which allows you to change the view mode of an entity via Context but the problem is that you might have lots of entities on a page, which entity should be changed now?
FYI I created a sandbox where I will put the code in.
Comment #19
phildu CreditAttribution: phildu commentedthe repository is empty ?
Comment #20
yannickooI have this on my machine. I need more information about the features as I described in #18.
Comment #21
swentel CreditAttribution: swentel commentedThe sandbox is there, work can go on there https://drupal.org/sandbox/yan_nick/1995902
Comment #22
j3ll3nlif you got a lot of entities on a page then it is managed by a view oid?
It should only work for the viewing of a single entity. Otherwise a view could manage the view mode and the context module.