I'm using cck to create some custom nodes, each node has a number of fields and is of course associated with a specific taxonomy term.

To style the cck node correctly i'm using the node-cckname.tpl.php method to create a template for the node.

I have some specific information that is the same for each node of the same taxonomy term. I need to hard code this info into the node-cckname.tpl.php.

The obvious way (to me) would be to use a php if statement to say "if taxonomy term is show:"...

ALAS!!! my php knkowledge is puny, and my Drupal knowledge is only sub-par. If someone could post the seemingly simple code, i'd be very happy!!!

Comments

jptaranto’s picture

With a little more search trawling I found a solution, not sure if it's the best but here goes:

		<?php $term_id_tid = 1; if (isset($node->taxonomy[$term_id_tid])): ?>
			<p>The info that is related to taxonomy term.</p>
		<?php endif; ?>

Where $term_id is set to whatever the tid of the term your targeting is.

miahawk’s picture

This helped me get past a problem I was having getting a link to display for a certain taxonomy term.

obviously, the taxonomy term in my case is 75, so I used it like this:

<?php $term_id_tid = 75; if (isset($node->taxonomy[$term_id_tid])): ?>
<a href="#" onclick="history.go(-1);return false;">Return to Gallery</a>  
<?php endif; ?>
Shinzon’s picture

What about array of terms? My PHP is not so good. I hope you understand what I want.

<?php $term_id_tid = 1,2,3,44,66,234; .....