vocabindex_page.tpl.php for each vocabulary?

iteego - June 17, 2009 - 13:53
Project:Vocabulary Index
Version:6.x-2.1
Component:Miscellaneous
Category:support request
Priority:normal
Assigned:Xano
Status:closed
Description

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

#1

Xano - June 17, 2009 - 17:30

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

iteego - June 17, 2009 - 17:59

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

Xano - June 17, 2009 - 18:07

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

iteego - June 17, 2009 - 18:57

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

#5

iteego - June 20, 2009 - 14:20

worked like a charm. Thanks!!

#6

Xano - June 20, 2009 - 16:26
Assigned to:Anonymous» Xano
Status:active» fixed

Good to hear that :)

#7

System Message - July 4, 2009 - 16:30
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.