I'd like to add some content to each vocabulary page. can i do something to create unique vocabindex pages based on the vocabulary index being shown? Cheers, Kevin

Comments

xano’s picture

Currently it's not possible to have multiple vocabindex_page.tpl.php files, but you can add content per vocabulary by using an if statement that checks if $parent is a vocabulary object and uses the VID to add the right data to the page.

Does this answer your question?

pyxio’s picture

it sounds like a perfect solution except that I'm not a php programmer ;o) can you provide a sample statement with two VID's? If not, I certainly understand and will use your advice to find a programmer who can write that for me. Many thanks and great module. Cheers, Kevin

xano’s picture

Voilà:

// $Id: vocabindex_page.tpl.php,v 1.1.2.6 2008/11/02 00:27:02 xano Exp $

/**
 * @file
 * Renders an index page.
 *
 * Available variables:
 * $parent      Either the VI object or a $term object.
 * $list        The list of terms.
 * $pager_alpha A pager to filter by first letter. Used for alphabetical lists.
 * $pager       A regular pager or NULL if unnecessary.
 */
if (!isset($parent->tid)) {
  switch ($parent->vid) {
    case 3:
      echo t('Dude, have you seen my car?');
      break;
    case 867:
      echo t('Geez, you got a lot of terms!');
      break;
    case 45:
      echo t("That's when the war ended");
      break;
  }
}
if ($parent->description) {
  echo '<p class="vocabindex-desc">' . $parent->description . '</p>';
}
echo $pager_alpha . $list . $pager_alpha . $pager;

The if statement checks if the parent is not a term (you can't for VID, since terms and vocabularies have that property). Then it checks the if the VID matches certain values (3, 867 and 45) and in this case echoes a string. You could also replace the echo statement with a function call or any other PHP code.

Good luck!

pyxio’s picture

wow. you rock. i will give it a shot tomorrow! a zillion thanks. K

pyxio’s picture

worked like a charm. Thanks!!

xano’s picture

Assigned: Unassigned » xano
Status: Active » Fixed

Good to hear that :)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

xano’s picture

Assigned: xano » Unassigned