Hi,
a typical thing I do with Display Suite is to make a node sub-page (tab / local task next to view, edit etc) via hook_menu(), and let it render the node in a custom build mode.
This can be creatively combined with custom fields and views_attach.module.
I wonder if we could simplify this process, so the admin / developer would have to do only one thing, to create the build mode and the router item at once.
I am undecided if this "one thing" should be to implement a hook (= code), or to click around in the admin backend. Maybe we can provide both.
I might help out with a patch, or even make a separate module for this, but would like to see some opinion first, and maybe some useful hints.
Thanks!
Comments
Comment #1
swentel commentedStarting with a hook sounds good enough for me. ND can implement hook_menu() and call a hook which pass in information. I guess that hook should only pass a title for the tab, and the build mode so we we can pass this on as a page argument. We'll probably have to use our own page callback, which will basically become a copy of node_page_view (say nd_page_view), with an extra param which will be the $build_mode.
I personally never had the need for such functionality, so not sure if we need to make this available already in the admin too. Depends how much you want to write I guess :)
Comment #2
donquixote commentedFor my taste, a hook is fine.
(and easier to deploy anyways)
Ok, I am sure I can figure out most of this myself.
The one thing I would ask you (so I don't have to investigate myself):
I want to automatically create a build mode for every page aspect.
The build mode name and machine name can by default be identical with the path suffix and the tab title, but I want the possibility to override this (so changing the path does not require changing the build mode name).
The question:
What is the best way to declare build modes programmatically, and not get in conflict with the user-created build modes?
Comment #3
donquixote commentedQuick update,
I have something working on my local test site, a module "nodeaspect" with a hook_nodeaspect() to define your own build modes and aspect pages.
It does create router items, permissions and build modes.
This is how your example module implementation would look like:
Please note that most of this is comments.
I wonder if we should aim to add this to any existing project (nd, nd_contrib) or make it a new project.
Comment #4
donquixote commentedAlso, I wonder if I can somehow manipulate the "exclude matrix" programmatically, if a build mode applies to only some node types.
Comment #5
swentel commentedThe exlude matrix is a bunch of variables - not the nicest way to store those settings, but it works in the 6 branch, see ds_build_modes_matrix_submit()
Comment #6
xtfer commentedUnless anyone is planning on updating this thread with more information about nodeaspect or a similar implementation, this is now closed. :)
Comment #7
donquixote commentedAnd.. here we go :)
http://drupal.org/project/nodeaspect