Adding a Node Build Mode
Q: if you need to add a dead simple view mode to theme a node template differently, basically give Views in addition to "full node", "teaser", a "bastard step-child" option, quick custom code or is a module?
http://drupal.org/project/buildmodes ?
A, by Fox: just do the hook. the hook is simple as hell
Q: and Views sees it automatically?
A: if say use views
http://drupalcontrib.org/api/drupal/contributions--cck--content.module/function/node_content_build_modes/6
For example (untested code, for custom_example.module):
<?php
/**
* Implements hook_content_build_modes().
*
* Provide a build mode for use with a view used on the recipient landing page.
*
* @TODO Belongs in a general-purpose CMA utility module, not a fit with media.
*/
function custom_example_content_build_modes() {
return array(
'custom_example' => array(
'title' => t('CMA'),
'build modes' => array(
'recipientspage' => array(
'title' => t('Recipients Landing Page'),
'views style' => TRUE,
),
),
),
);
}
?>
Note: Do not follow the example of Full Node and Teaser and use 'basic' as the first array key— this results in your build mode addition not adding to but replacing those two existing build modes. Instead, where custom_example is used here, use the name of your module as this guarantees no namespace conflict.
Comments
Post new comment