Monday, May 25, 2009

Add Collapsible text/fields in D6 page

Add following code to the body field.

Do not forget to change Input Format to PHP.


<?php
drupal_add_js('misc/collapse.js');
?>

<fieldset class="collapsible collapsed">
<legend class="collapse">
<a href="#">New subscriber questions</a>
</legend>
<div class="fieldset-wrapper">
This is the fieldset content....you can have anything here
</div>
</fieldset>

Sunday, May 24, 2009

Print vocabulary terms associated with node

Following code will print vocabulary terms associated with node in block.

$vid is the vocabulary. In my case its value is 2.


<?php
/**
* Prints an unordered list of the terms (as links) that are
* associated to the currently displayed node.
*/
if ( arg(0) == 'node' && is_numeric(arg(1)) ) {
$node = node_load(arg(1));
$vid = 2;
$terms = taxonomy_node_get_terms_by_vocabulary($node, $vid);
if ($terms) {
print '<ul>';
foreach ($terms as $term) {
print '<li>'.l($term->name, 'taxonomy/term/'.$term->tid).'</li>';

}
print '</ul>';
}
}
?>