1

I have done a drupal theme and as of right now am only working with teaser and full view modes. Both of which I have themed in the node--product.tpl.php file I am interested in learning view modes to create different, fully customizable layouts for different pages and products.

How and where to create a new view mode for a paticular node type ie. Node--product.tpl.php before themeing. Is there a preferred module for this which doesn't limit themeing. How and where to tell a given page ie. Page--front.tpl.php which view mode of a paticular node type to use. Is there a module for this. As of now the product nodes appear under the content region.

How and where to theme the html of a view mode. Even if it's a template override. Right now I have the two view modes themed in a photo if else statement. The "if" being the teaser and the "else" being the full node. Any tutorials or videos that stand out for this?

1

You should take a look at Display Suite. It makes easy work of most template modifications without having to create .tpl.php files. It has an easy to understand method of managing View Modes.

From the above link:

Use custom view mode

  1. Enable DS UI module.
  2. Go to Administration > Structure > Display Suite > View modes (admin/structure/ds/view_modes)
  3. Click "Add a view mode"
  4. Enter a label & define to which entities the mode will be made available
  5. Click "Save"
  6. Go to Administration > Structure > Display Suite (admin/structure/ds)
  7. Click "Manage display" for the entity (e.g., "User") whose display you like to change
  8. Choose the vertical tab "Custom display settings"
  9. Enable the new view modes
  10. Click "Save"
  11. Flush all caches
  12. Choose the custom view mode from the secondary tabs in the top of the page.
  • Would this prevent me from creating an entirely new html layout with the needed php snippets for a new view mode I create through display suite? – user32026 Jun 12 '14 at 20:55
  • Every view mode you create through display suite can have its own html layout – Patrick Ryan Jun 12 '14 at 21:34
0

It sounds to me like you need theme suggestions for your view modes, which you can create as above, or programmatically, in a custom module:

  function my_view_modes_entity_info_alter(&$info) {
  $info['node']['view modes'] += array(
    'my_view_mode' => array(
      'label' => t('My View Mode'),
      'custom settings' => TRUE,
    ),
  );

Theme suggestions for your View Modes is explained here - D7 Template Suggestions for View Modes

0

I actually found the best way to create and edit new view modes is to just use entity view modes. This was I can create the view mode and create .tpl.php files for them.

The only issue that remains is how I tell a given url / page ie. page--front.tpl.php or page--taxonomy--term.tpl.php which view mode of a content type to use as well as what to limit the number of nodes per page to display

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.