Buna,
Am si eu o problema: nu reusesc sa pun un block pe anumite pagini.
In acest block am mai multe linkuri care sunt termeni dintr-o taxonomie (ex de link: .../directory/74).Cand intru pe pagina respectiva, am mai multe noduri. Dau click pe un nod, ma duce in full node.
Am setat blocul sa imi apara pe paginile cu directory. Dar vreau sa imi apara si pe nodurile care sunt in directory- in full nodes (de exemplu in directory/73 am 50 de noduri iar blocul vreau sa imi apara si pe nodurile astea).
Can anyoane help me, pls?:)
Oana
Merge! Merci!
<?php
if (arg(0) == 'directory' && is_numeric(arg(1)) && in_array(arg(1), array(75, 158)) && arg(2) == FALSE) {
return TRUE;
}
// put here the term ID you're interested in
$desired_term = 74;
$ar_dir= array(74, 158, 157);
if ( arg(0) == 'node' and is_numeric(arg(1)) and arg(2) == FALSE ) {
// Yes, we're viewing a node in view mode.
$node = node_load(arg(1)); // cached
// If the term does not exist we're done
if (is_array($node->taxonomy)) {
foreach ($node->taxonomy as $term) {
if (in_array($term->tid, $ar_dir) ) {
return TRUE;
}
}
}
}
return FALSE;
?>
Am rezolvat cu nodurile:
<?php
// This snippet returns TRUE if the node we are
// currently viewing is tagged with a term which is
// the 'desired_term' and we are not in edit mode (arg(2)).
// put here the term ID you're interested in
$desired_term = 74;
$ar_dir= array(74, 158, 157);
if ( arg(0) == 'node' and is_numeric(arg(1)) and arg(2) == FALSE ) {
// Yes, we're viewing a node in view mode.
$node = node_load(arg(1)); // cached
// If the term does not exist we're done
if (is_array($node->taxonomy)) {
foreach ($node->taxonomy as $term) {
if (in_array($term->tid, $ar_dir) ) {
return TRUE;
}
}
}
}
return FALSE;
?>
Mai ramane sa imi afiseze directoarele de mai sus (directory/74, 158...)
HELP!ANYONE?! Voi ramane vesnic recunoscatoare! :)
Buna,
Am incercat cu ce mi-ai dat tu si nu a mers atat de bine:)
Am gasit in schimb un php snippet de genu:
<?php
// This snippet returns TRUE if the node we are
// currently viewing is tagged with a term which is
// the 'desired_term' and we are not in edit mode (arg(2)).
// put here the term ID you're interested in
$desired_term = 74;
if ( arg(0) == 'node' and is_numeric(arg(1)) and arg(2) == FALSE ) {
// Yes, we're viewing a node in view mode.
$node = node_load(arg(1)); // cached
// If the term does not exist we're done
if (is_array($node->taxonomy)) {
foreach ($node->taxonomy as $term) {
if ($term->tid == $desired_term) {
return TRUE;
}
}
}
}
return FALSE;
?>
Imi arata blocul pe toate nodurile din directory/74. Eu mai vreau 2 lucruri:
1. Sa imi arate nodurile si din alte vocabularies (de ex: directory/75, directory/112, etc...)
2. Sa imi arate blocul si pe vocabularele de mai sus.
Ma gandeam ca in $desired_vocab sa pun un array in care sa insir eu vid-urile. Dar nu merge..
Alte idei?
Merci, Oana
Merci mult!Am sa incerc sa vad daca merge!
Utilizează modul PHP şi determină din cod care pagini vrei să fie afişate.
De exemplu:
<?php
if (arg(0) == 'directory' && in_array(arg(1), array(73, 74, 75)) {
return TRUE;
}
if (arg(0) == 'node' && is_numeric(arg(1) && is_null(arg(2))) {
if (<...aici se testeaza daca nodurile apartin unor termeni din clasificare>) {
return TRUE;
}
}
return FALSE;
?>
Sper să ajute...