Два условия видимости блока с php кодом

Главные вкладки

Аватар пользователя qazaq qazaq 10 февраля 2010 в 13:17

Нужно вывести один блок на страницах определенного типа материла и на определенных страницах.
Нашел нужные кусочки кода:


<?php
$match 
FALSE;
$types = array('тип материала' => 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])) {
    
$match TRUE;
  }
}
return 
$match;
?>

и


<?php
$desired_paths 
= array('перечисление страниц');
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;
    }
}
return 
FALSE;
?>

Как можно объеденить эти два кода? Или нужно выводить два одинаковых блока с разными условиями?

Комментарии

Аватар пользователя glu2006 glu2006 10 февраля 2010 в 13:30

А логику включить никак?

<?php
$desired_paths 
= array('перечисление страниц');
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);
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;
?>