User login

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

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.