Short version: Any interest in adding a filter_node_content_views hook to Views_Attach? If so, I will create patch from the code below.
Details:
I need to have a way to choose between node content views based on a CCK field in the node being displayed. E.g., there is a single "course materials" type that displays related "material" type nodes. A "course materials" node could have a display_type CCK field set to "prework" or "session". If the display_type is set to "prework", the materials are listed by due date and title. If the display_type is set to "session", the materials will be sorted by time slot, presenter, and material (e.g. PPT deck, handouts, and the like).
I could do this with duplicate material types and different nodes, but I want to simplify things for my users.
To solve this, I am planning on doing the following:
Create two different views with node content displays and associate them with the "course materials" type.
Modify the views_attach_nodeapi function to call a "filter_node_content_views" hook with the $node and $&views arguments after the views_attach_get_node_views call is made. This hook can be used by another module to remove views before they are added to the node display.
This will solve my problem and I IMHO add a nice bit of flexibility to this wonderful module. But given the state of it's maintenance, I don't want to do a lot of extra work if no one else is interested.
Comment | File | Size | Author |
---|---|---|---|
#1 | views_attach-1132122-1.patch | 1.77 KB | cgmonroe |
Comments
Comment #1
cgmonroe CreditAttribution: cgmonroe commentedWell, I thought this would take longer and I'd get some feedback before I got finished... but it was fairly trivial. If anyone wants it, the patch is attached below.
Here's a sample hook implementation from my module. This let users select the node content view type to use by setting a CCK field value.