Calling the images?
chasz - August 28, 2008 - 16:38
| Project: | Taxonomy Image |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | support request |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
<?php
foreach (taxonomy_node_get_terms($node->nid) as $term) {
if ($image = taxonomy_image_display($term->tid, "align='right'")) {
print "<a href='taxonomy/term/" . $term->tid . "'>" . $image . "</a>";
}
}
?>why cant i call the image with this in the teaser?

#1
hello i put it into my theme node.tpl.php so why wont it show ?? :D
#2
Hi,
I'm not quite sure if this is similar issue, but I am using recursive image display.
I've added this code to node.tpl.php (and I use the pixture theme)
foreach (taxonomy_node_get_terms($node->nid) as $term) {
echo "Debug : tid is ". $term->tid."<br>";
echo "Debug : term name is ". $term->name."<br>";
if ($image = taxonomy_image_display($term->tid)) {
$output .= "$image";
}
}
echo $output;
The resultant is :
Debug : tid is 329Debug : term name is ACHESON
... so both of these bars are known .... but $output always returns a null.
The term ACHESON does not have a taxonomy image added, but it's parent does.
Happy to answer any questions in hope of a solution.
Many thanks in advance.
D.
#3
can anyone help us ?
#4
Both of those look like they should work (although I am not a theme guru). However it is unnecessary; the taxonomy_image_link_alter add-on module will do that for you with no theme changes.
#5
that addon sounds like it replaces the link with an image
with this we would like to add addition image link at another location
i justr would like to see the variable and we theme it
#6
Here's a working template:
<?php
echo '<div id="node-'. $node->nid .'" class="node'. ($sticky ? ' sticky' : NULL) . ($status ? NULL : ' node-unpublished') .'">';
echo $picture;
if ($page == 0) {
echo '<h2><a href="'. $node_url .'" title="'. $title .'">'. $title .'</a></h2>';
}
if ($submitted) {
echo '<span class="submitted">'. $submitted .'</span>';
}
echo '<div class="content clear-block" style="background:#ffe8e8;">'. $content .'</div>';
echo '<div class="clear-block"><div class="meta">';
if ($taxonomy) {
// echo '<div class="terms">'. $terms .'</div>';
// $output = NULL;
$output = t('Tags:') .' ';
foreach ($node->taxonomy as $term) {
if ($image = taxonomy_image_display($term->tid)) {
$output .= "$image";
}
}
echo $output;
}
echo '</div>';
if ($links) {
echo '<div class="links">'. $links .'</div>';
}
echo '</div>';
echo '</div>';
#7
temp
Automatically closed -- issue fixed for two weeks with no activity.
#8
Automatically closed -- issue fixed for two weeks with no activity.
#9
NancyDru
I copied your code, but it won't work for me, the image doesn't display.
In my node.tpl.php file I have:
<?php
$spaces = db_fetch_array(db_query("SELECT stock FROM {uc_product_stock} WHERE nid = $node->nid"));
?>
<div class="node <?php print $node_classes ?>" id="node-<?php print $node->nid; ?>"><div class="node-inner">
<?php if ($page == 0): ?>
<h2 class="title">
<a href="<?php print $node_url; ?>"><?php print $title; ?></a>
</h2>
<?php endif; ?>
<?php if ($unpublished) : ?>
<div class="unpublished"><?php print t('Unpublished'); ?></div>
<?php endif; ?>
<?php if ($picture) print $picture; ?>
<?php if ($submitted): ?>
<div class="submitted">
<?php print $submitted; ?>
</div>
<?php endif; ?>
<div class="content">
<table width="100%">
<tr>
<td width="70%" rowspan="4" valign="top"><?php print $node->content['body']['#value'] ?></td>
<td>
<?php
echo '<div class="clear-block"><div class="meta">';
if ($taxonomy) {
foreach ($node->taxonomy as $term) {
if ($image = taxonomy_image_display($term->tid)) {
$output = "$image";
}
}
echo $output;
}
echo '</div>';
?>
</td>
</tr>
<tr>
<td>
<div class="field field-type-text field-field-location">
<h4 class="field-label">Location:</h4>
<div class="field-items">
<div class="field-item"><?php print $node->field_location[0]['view'] ?></div>
</div>
</div>
</td>
</tr>
<tr>
<td>
<div class="field field-type-text field-field-location">
<h4 class="field-label">Start Date:</h4>
<div class="field-items">
<div class="field-item"><?php print $node->start_format ?></div>
</div>
</div>
</td>
</tr>
<tr>
<td>
<div class="field field-type-text field-field-location">
<h4 class="field-label">Spaces Available:</h4>
<div class="field-items">
<div class="field-item"><?php if ($spaces['stock'] > 0) { echo $spaces['stock']; } else { echo "<span style='color: red'>No spaces available</span>"; } ?></div>
</div>
</div>
</td>
</tr>
</table>
<?php if ($spaces['stock'] > 0) { print $node->content['add_to_cart']['#value']; } ?>
</div>
<?php if ($links): ?>
<div class="links">
<?php print $links; ?>
</div>
<?php endif; ?>
</div></div> <!-- /node-inner, /node -->
?>
It won't display the image..... I know the image is loaded correctly; I can see it when I edit my taxonomy.
Thanks
Glenn