After a painful day and a half I get this code, that prints out in my node.tpl.php the taxonomy terms associated to that particular node that the user is viewing.
It works just fine. As it is quite long I´ll just put the whole thing inside a module and into a variable, to just print that.
The thing is that it should get an easier, better way to do this! Any ideas?
<?php $vid = 11; //vocabulary id $nid = $node->nid; //it looks for the current loaded node $query = "SELECT tid, name FROM ( SELECT td.tid AS tid, name FROM taxonomy_term_data AS td JOIN taxonomy_index AS tn ON td.tid = tn.tid JOIN node AS n ON n.nid = tn.nid WHERE td.vid = ". $vid ." AND n.status = 1 AND n.nid = ".$nid." GROUP BY td.tid ) AS t ORDER BY name ASC"; $result = db_query($query); foreach($result as $term) { echo l($term->name, "taxonomy/term/$term->tid") . ', '; } ?>
UPDATE:
This is devel output: (I´ve used (dpm($node);
) because it let me print the result here without losing the indentation)
(object) array( 'vid' => '5178', 'uid' => '1', 'title' => 'PROYECTO', 'log' => '', 'status' => '1', 'comment' => '2', 'promote' => '0', 'sticky' => '0', 'nid' => '155', 'type' => 'jornadas', 'language' => 'und', 'created' => '1095048000', 'changed' => '1360589684', 'tnid' => '0', 'translate' => '0', 'revision_timestamp' => '1360589684', 'revision_uid' => '1', 'taxonomy_vocabulary_4' => array(), 'taxonomy_vocabulary_6' => array( 'und' => array( array( 'tid' => '33', 'taxonomy_term' => (object) array( 'tid' => '33', 'vid' => '6', 'name' => 'Jornadas Gratuitas', 'description' => '', 'format' => NULL, 'weight' => '0', 'vocabulary_machine_name' => 'vocabulary_6', ), ), ), ), 'taxonomy_vocabulary_7' => array( 'und' => array( array( 'tid' => '40', 'taxonomy_term' => (object) array( 'tid' => '40', 'vid' => '7', 'name' => 'Para PH', 'description' => '', 'format' => NULL, 'weight' => '-10', 'vocabulary_machine_name' => 'vocabulary_7', ), ), ), ), 'taxonomy_vocabulary_11' => array( 'und' => array( array( 'tid' => '262', 'taxonomy_term' => (object) array( 'tid' => '262', 'vid' => '11', 'name' => 'colegios', 'description' => '', 'format' => NULL, 'weight' => '0', 'vocabulary_machine_name' => 'vocabulary_11', ), ), array( 'tid' => '543', 'taxonomy_term' => (object) array( 'tid' => '543', 'vid' => '11', 'name' => 'derecho', 'description' => '', 'format' => NULL, 'weight' => '0', 'vocabulary_machine_name' => 'vocabulary_11', ), ), ), ), 'body' => array( 'und' => array( array( 'value' => "