SMOLNET PORTAL home about changes

collapsible content using contemplate

How to make a collapsible content body with Contemplate and the Drupal core “collapsible” function?

Contemplate (http://drupal.org)


Make sure you’ve Contemplate enabled (through admin/build/modules)

Go to admin/content/templates and 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

Add collapsible content in Drupal @ Random Snippets (http://www.codesnippet.info)


https://web.archive.org/web/20071219000000*/http://drupal.org/project/contemplate (https://web.archive.org)
https://web.archive.org/web/20071219000000*/http://www.codesnippet.info/?p=52 (https://web.archive.org)
Response: 20 (Success), text/gemini
Original URLgemini://chirale.org/2007-12-19_b424813374ee24bd99b2fc0b1...
Status Code20 (Success)
Content-Typetext/gemini; charset=utf-8