Доброго дня,
нужно вывести блок для нод определенного типа (2 разных типа) и одной ноды по айди.
Нашел код:
<?php
if ((arg(0) == 'node') && is_numeric(arg(1))) {
$node = node_load(arg(1));
return $node->type == 'type1';
}
?>
if ((arg(0) == 'node') && is_numeric(arg(1))) {
$node = node_load(arg(1));
return $node->type == 'type1';
}
?>
он выводит блок для всех материалов типа type1 как мне сюда добавить еще type2 и айди ноды?
Спасибо
Комментарии
Спасибо, помогли
$desired_paths = array('путь_1', 'путь_2');
if ($_GET['q']) {
$my_drupal_path = $_GET['q'];
} else {
$my_drupal_path = substr($_SERVER['REQUEST_URI'], 1);
}
$my_path_alias = drupal_get_path_alias($my_drupal_path);
foreach ($desired_paths as $desired_path) {
if (stristr($my_path_alias, $desired_path)) {
return TRUE;
}
}
$types = array('тип_1' => 1, 'тип_2' => 1);
if (arg(0) == 'node' && is_numeric(arg(1))) {
$nid = arg(1);
$node = node_load(array('nid' => $nid));
$type = $node->type;
if (isset($types[$type])) {
return TRUE;
}
}
return FALSE;
?>
<?php if (arg(0) == 'node' && is_numeric(arg(1) && !arg(2)) {
$types = array('page', 'story', 'another_type'); // Ваши типы нод
$ids = array(1, 2, 3); // Нужнае айдишки
$node = node_load(arg(1));
if (
in_array($node->type, $types)) {return TRUE;
}
else if (in_array($node->nid, $ids)) {
return TRUE;
} else {
return FALSE;
}
}
?>Что то типа так. Не проверял