Download & Extend

vocabindex_page.tpl.php for each vocabulary?

Project:Vocabulary Index
Version:6.x-2.1
Component:Miscellaneous
Category:support request
Priority:normal
Assigned:Xano
Status:closed (fixed)

Issue Summary

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

#1

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?

#2

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

#3

Voilà:

<?php
// $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!

#4

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

#5

worked like a charm. Thanks!!

#6

Assigned to:Anonymous» Xano
Status:active» fixed

Good to hear that :)

#7

Status:fixed» closed (fixed)

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