Ok, prima di tutto grazie 1000 ad entrambi, ma devo arrendermi alla mia ignoranza in questo campo.
Faccio un riepilogo inserendo questa volta anche le motivazioni e lo script da modificare per intero, così ci si capisce meglio.
Sto usando Drupal e devo rendere visibile un blocco (un menu) solo nelle pagine che sono taggate con uno dei termini della array e del menu stesso. Quindi se il codice restituisce TRUE il blocco è visibile, altrimenti no. Sottolineo che lo script originale funziona perfettamente ed è questo:
Codice PHP:
<?php
$myterms = array(39, 59, 85, 114); // list the ids of the terms you want
// This will show on all nodes having this term
if ((arg(0) == 'node') && is_numeric(arg(1))) {
$terms = taxonomy_node_get_terms(node_load(arg(1)));
foreach($terms as $term) {
if (in_array($term->tid, $myterms)) return TRUE;
}
}
// This will show on the index page for that term
if ((arg(0) == 'taxonomy') && (arg(1) == 'term') && (in_array(arg(2), $myterms))) {
return TRUE;
}
// Otherwise
return FALSE;
?>
Ho eliminato
Codice PHP:
$myterms = array(39, 59, 85, 114);
che non serve più ed ho inserito lo script di Nicola:
Codice PHP:
<?php
$myterms = array();
$iuno = 50;
$funo = 55;
$idue = 78;
$fdue = 86;
echo '<pre>';
$myterms = range($iuno,$funo);
print_r($myterms);
$myterms = array_merge($myterms,range($idue,$fdue));
print_r($myterms);
// This will show on all nodes having this term
if ((arg(0) == 'node') && is_numeric(arg(1))) {
$terms = taxonomy_node_get_terms(node_load(arg(1)));
foreach($terms as $term) {
if (in_array($term->tid, $myterms)) return TRUE;
}
}
// This will show on the index page for that term
if ((arg(0) == 'taxonomy') && (arg(1) == 'term') && (in_array(arg(2), $myterms))) {
return TRUE;
}
// Otherwise
return FALSE;
?>
Il risultato è che il blocco è SEMPRE visibile, e non solo nel range indicato.
Chi ne capisce di più forse può capire dove sta l'inghippo, io non ne sono in grado.