How to make a collapsible content body with Contemplate and the Drupal core “collapsible” function?
- Make sure you’ve Contemplate enabled (through admin/build/modules)
- Go to
admin/content/templatesand choose the type you want to display collapsible content within. - Enable body contemplate checking “Affect body output” and write (change field names):
<?php
drupal_add_js(’misc/collapse.js’);
drupal_add_js(’misc/drupal.js’);
?>
<fieldset class=”collapsible collapsed”>
<legend><?php print t(”My Translatable First Field Label”)?></legend>
<div class=”fieldset-wrapper”>
<h2><?php print t(”My Translatable First Field Header”)?></h2>
<?php print $node->field_myfirstfield[0]['view'] ?>
</div>
</fieldset><div class=”mysecondfield”>
<?php print $node->field_mysecondfield[0]['view'] ?>
</div>
Update: If you want a collapsible box expanded by default, use class=”collapsible” without “collapsed” class.
See also:
Add collapsible content in Drupal @ Random Snippets

Thanks for the code snippet.