Adding a collapsible fieldset on node view

To add a collapsible fieldset in node view, like the fieldsets in edit view, you first have to make sure to load the JavaScript to node view. If you wan this feature on only one page you can add the script tag directly in the body content (if your filter allows script). If you want this feature on more than one/some node you can load the script from template.

To add in node content or in page.tpl.php:
<script type="text/javascript" src="/misc/collapse.js?"></script>

If you want to add it in your module you can use:
<?php
drupal_add_js
('misc/collapse.js');
?>

To call this feature add the following in your node content

<form>
<fieldset class="collapsible collapsed">
  <legend>Title</legend>
   <div>The collapsed field</div>
</fieldset>
</form>

Example


Knowledge keywords: