Creating this feature request based on a comment by ausnahmezustand over on #1397676: Support for Views with contextual filter.
In addition to the Field and View data sources that are available now, the different view modes of the node itself should also be available as the content of a subpage. This would allow site admins to make use of Display Suite to configure different view modes for the content type—displaying different fields in different regions in each view mode—and use those for the subpages.
Implementing this will require some structural changes to the module: the list of data sources (when adding/editing a subpage on a content type) and the content used for a subpage are handled in node_subpages
. Support for Views and Fields are coded right into node_subpages_add_subpage()
and node_subpages_view()
, but instead, these functions should be invoking hooks to allow other modules to supply a list of potential data sources, and to supply the content for a subpage. node_subpages
will then implement these hooks (always eat your own dog food!) to provide the existing Field and Views support.
Todo:
- Add a
source_module
column to thenode_subpages
table. This will store the name of the module providing the data for the subpage. Also need an update function to add this column to existing installs. - In
node_subpages_add_subpage()
, invokehook_node_subpages_data_sources
to get a list of data sources. Modules implementing this hook should provide:- Module name
- Data types provded (field, views, node_view_mode, etc)
- List of sources for each data type (list of fields, list of views, list of view modes, etc)
When the admin chooses their data source, the three values will be stored in the
node_subpages
table. - Implement
hook_node_subpages_data_sources()
in thenode_subpages
and move the Fields and Views support into that function (fromnode_subpages_add_subpage()
) - In
node_subpages_view()
, invokehook_node_subpages_content
on the module that provides the data source selected for the subpage. This hook should return a render array. - Implement
hook_node_subpages_content
innode_subpages
, and move the current Fields and Views logic to that function fromnode_subpages_view()
.
Adding these hooks will allow other contrib modules to add data sources for subpages, if other people are interested in doing so, and can be used to add support for view modes:
- Create a new
node_subpages_ds
module to contain this functionality. It will list Display Suite as a dependency. - Implement
hook_node_subpages_data_sources
andhook_node_subpages_content
in the newnode_subpages_ds
module. The site admin will be able to select any view mode to use when making use of the view mode data source.
Comment | File | Size | Author |
---|---|---|---|
#6 | content_plugin_node_view_mode-1429368-6.patch | 3.27 KB | michaellander |
Comments
Comment #1
ausnahmezustand CreditAttribution: ausnahmezustand commentedToday i´m starting with a new local installation for theming a side. Your module is one of primary parts in this case!! My customer needs a contenttyp for displaying infos, gallery, geo-map and more for his stores in different towns. The way with different content-typs and node-references is not the best solution, he wants a one-in-all.
For the moment i take the way with viewmodes for basiclayouts and displaying with a view in the subpage. I think for the future of your modul, the implementation of the native use of a node-viewmode is a great goal:
- Option 1 - use of textfields for the easy and fast development of subpages with textual content.
- Option 2 - native use of node-viewmodes for different layouts, and the configuration rich content
- Option 3 - use of views
Best regards
Comment #2
BrockBoland CreditAttribution: BrockBoland commentedJust so we're on the same page: I'm not sure how soon I'll be able to add this functionality. If you need to launch a new site with this stuff in the near future, you may want to consider a different solution. Or if you're a coder, I always welcome patches :-)
Comment #3
ausnahmezustand CreditAttribution: ausnahmezustand commentedI´m not a coder, more a themer... Basic work with php is no problem, also the development of small modules like a custom content typ, custom fields...
But for this time your module is the right thing... i will take it for three different contenttyps:
#1 only text fields / 3 subpages
#2 with 3 subpages: two subs i take the node_viewmods with displaysuit-layout + two easy views ("typ is content of displaysuit nodeviewmode xxx"+context by node id/url), one is a gallery (view with context by node id/url + show field_custom_img in a floating grid + custom lightbox "highslide" by click)
#3 is one the same view like #2 (gallery) + one with displaysuitlayout + one with textfield
At the moment i have warning-messages on the (only on) subpages when i modified it with a displaysuit-layout. But my actual installation of drupal is a new fresh one, and at the moment i work on basic structur, without the final theme. In one of the next days i will integrate it, and then i know more about...
--UPDATE--
No warning messages with my basic html5-theme.
--UPDATE--
Comment #4
BrockBoland CreditAttribution: BrockBoland commentedQuick update: this will be in 2.0 when it's released.
Comment #5
inders CreditAttribution: inders commented- Added view mode for node subpages
- Provided support for all field types (tested with image, colorbox, nodereference fields)
- Display configurations are taken as are configured for "Node subpage" display from content type => Display page.
Added patch @ http://drupal.org/node/1544068#comment-7290894
Thanks & Regards
-Inder Singh
http://indersingh.com
Comment #6
michaellander CreditAttribution: michaellander commentedThis should do it. Someone please review.
Comment #7
michaellander CreditAttribution: michaellander commentedComment #8
RAFA3L CreditAttribution: RAFA3L commentedThanks @michaellander, work fine here even with Display Suite, maybe this must be the default option for this module.