Module taxonomy_image : associer une image à un terme ?

j'ai tout fais ce qui est dit de faire sauf ca car je comprend pas :

___________________________________________________________
Step 7)
Update your theme or other php code to display taxonomy images.

To display a taxonomy image from your theme or other php code, add
a call to taxonomy_image_display(). This function requires that you pass
in the term id of the term for which you wish to display the appropriate
image. For example:
taxonomy_image_display($term->tid)

This will return an img tag with the appropriate values for source=,
height=, width= and alt=. For example, it may return something like:
img src='files/image.jpg' width='75' height='75' / alt='term name'
___________________________________________________________

merci


Damien Tournoud
Posts: 523
Joined: 2005-08-02

Ton texte doit faire référence aux fonctions qui affichent les termes d'une node. La variable $node->taxonomy, accessible depuis ton node.tpl.php contient une liste de $term.

A la place de ton

<?php
print $terms
?>
, tu peux donc faire un truc dans ce genre:

<?php
    $links
= array();
    if (
array_key_exists('taxonomy', $node)) {
      foreach (
$node->taxonomy as $term) {
        if (
$image = taxonomy_image_display($term->tid)) {
            
$links[] = l($image, taxonomy_term_path($term),
               array(
'rel' => 'tag', 'title' => strip_tags($term->description)),
              
NULL, NULL, FALSE, TRUE);
        }
        else {
            
$links[] = l($term->name, taxonomy_term_path($term),
               array(
'rel' => 'tag', 'title' => strip_tags($term->description)));
        }
      }

      print
theme('links', $links, array('class' => 'links inline'));
    }
?>

Pour info, je me suis basé sur la fonction taxonomy_link pour écrire cette fonction modifiée.

--

Damien Tournoud



jubjub
Portrait de jubjub
Posts: 329
Joined: 2006-06-22

wouaaa super on me repond !!
je suis pas calé en php alors MERCI pour ton aide !!!!

mais ca ne marche pas, a la place du terme c'est marqué le nom de la classe "link inline" et je n'ai plus les "links" meme si je supprime les codes du tpl.

voila le contenu de mon node.tpl

<div class="node<?php if ($sticky) { print " sticky"; } ?><?php if (!$status) { print " node-unpublished"; } ?>">

    <?php if ($picture) {
      print
$picture;
    }
?>

    <?php if ($page == 0) { ?>
<h2 class="tax">
<div class="tax1">
<div class="tax2">
<div class="tax3">
<div class="tax4">


<a href="<?php print $node_url?>"><?php print $title?></a> </div>
</div> </div>
</div>
</h2>

  <?php }; ?>
  <span class="submitteddd">
  <div class="soumission">  <?php print $submitted; ?></div>
  <?php if ($node->type<>'page_'?>
   </span> <span class="taxonomy"><?php print ' Terme(s) : ';?><?php print $terms?>
</span>
  <div class="content"><?php print $content?></div>
   
  <div align="right"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><a href=""><img src="files/img/graphisme/ecouter/VOTES/vote-<?php print theme_nodevote_display_vote($node->nid); ?>.jpg"  ></a></font></div>
  </div>
   
  <?php if ($links) { ?>
  <font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif">
  </font>
  <div class="links"><?php print $links?></div>
  <?php }; ?>
  <font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"></font>
</div>



Damien Tournoud
Posts: 523
Joined: 2005-08-02

Ca m'apprendra à regarder directement dans le CVS. Remplace la dernière ligne par

<?php
print theme('links', $links);
?>

Sinon il y a un conflit entre deux variables dans ton node.tpl.php: la variable $links que j'ai défini et celle qui existait déjà. Alors tu peux remplacer tous les $links dans mon code par quelque chose du genre $imgterms.

--

Damien Tournoud



jubjub
Portrait de jubjub
Posts: 329
Joined: 2006-06-22

humm ca marche pas j'ai un message d'erreur php a la derniere ligne dans laquelle ya pas de code !
tu pourrais m'insérer TON code dans le mien et supprimer ton code pour links et garder le mien ?
je t'en serais tres reconnaissant !
j'ai un peu honte mais bon....
merci !