taxonomy description text for top of lists in Drupal 5

put this in the template.php ->

=========================================================

function _phptemplate_variables($hook, $vars = array()) {
switch ($hook) {
case 'page':
if (arg(0) == 'taxonomy') { //check to see if this is a taxonomy page
$vars['term_description'] = ''; //create a new template variable
$vars['vocab_description'] = ''; //create a new template variable
$a2 = arg(2); //get the term id
if(is_numeric($a2)) {
$result = db_query(db_rewrite_sql("SELECT vid, description FROM {term_data} td WHERE td.tid = %d"), $a2);
$this_term = db_fetch_object($result);
//save the term description
$vars['term_description'] = $this_term->description;

$vocab_result = db_query(db_rewrite_sql("SELECT description FROM {vocabulary} WHERE vid = %d LIMIT 1"), $this_term->vid);
$this_vocab = db_fetch_object($vocab_result);
//save the vocabulary description
$vars['vocab_description'] = $this_vocab->description;
}
}
break;
}
return $vars;
}

put this in page.tpl.php ->
=========================================================
(replace the #php with ?php ;)

<#php if (!empty($vocab_description)) { ?>

<#php print $vocab_description; ?>

<#php } ?>
<#php if (!empty($term_description)) { ?>

<#php print $term_description; ?>

<#php } ?>




Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <c>, <cpp>, <drupal5>, <drupal6>, <java>, <javascript>, <php>, <python>, <ruby>. The supported tag styles are: <foo>, [foo].

More information about formatting options

Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.
Bg