Problem theme-ing menu

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
Kristina Katalinic's picture

ok ekipa,
pokusavam prebacit temu crystalline od rocket theme na omega 3.x subtheme da bi dobio HTML5 i responsive temu i to ide ok ali sam naletio na cudan problem sa menijem...ok znam da se meni moze rijesit i preko nice menus ili superfish ali ja sam bas zapeo da to odradim preko teme.

najcudnija stvar je to da ovaj kod radi bez problema sa originalnom temom ali kad se stavi u omega problemi....pa kontam ako to iko moze rjesit to su balkanci :)

Problem je sto kod izgleda radi napola jer dok nemam nijedan expanded menu item sve sljaka prema planu no medjutim cim imam expanded menu item (a treba mi submenu) dobijem praznu stranicu ....znaci nula bodova.

Jel ima neko rjesenje taman da je i u stilu da samo dobijem "dfission" menutype s tim bi mogao zivjet |-:

znaci u region--menu.tpl.php stavim :

<?php if($crystalline_menutype != "none") : ?>
                           <?php
                               $tree
= menu_tree_page_data('main-menu'); 
                             
$main_menu = main_menu_tree_output($tree, 1);
                              print
$main_menu;  
                          
?>

                      <?php endif; ?>

funkcija u template.php ide ovako:

//********************************************
// PRIMARY LINK MENU ITEM INFO
//********************************************

/
* Returns a rendered menu tree.
*
* @param $tree
*   A data structure representing the tree as returned from menu_tree_data.
* @return
*   The rendered HTML of that data structure.
*/
function main_menu_tree_output($tree) {
  $output = '';
  $items = array();

  if( isset( $_COOKIE['crystalline_menutype'] ) )
   $this_mtype = $_COOKIE['crystalline_menutype'];
  else
  $this_mtype = theme_get_setting('menutype');
  // Pull out just the menu items we are going to render so that we
  // get an accurate count for the first/last classes.
  foreach ($tree as $data) {
    if (!$data['link']['hidden']) {
      $items[] = $data;
    }
  }

  $num_items = count($items);
  foreach ($items as $i => $data) {
   
    $extra_class = NULL;
    //$extra_class = get_link_color($items[$i]['title']);
   
    if (stristr($i, 'active')) {
        $extra_class .= " active";
      }
   
   
    if ($i == 0) {
      //$extra_class = 'first';
    }
    if ($i == $num_items - 1) {
      //$extra_class = 'last';
    }
    $link = main_menu_item_link($data['link'], $data['link']['has_children']);
  
    if ($data['below']) {
      $extra_class = "parent ";
      if($this_mtype == "splitmenu") {
          $output .= main_menu_item($link, $data['link']['has_children'], '', $data['link']['in_active_trail'], $extra_class);
      } 
      else {  
       $output .= main_menu_item($link, $data['link']['has_children'], sub_menu_tree_output($data['below']), $data['link']['in_active_trail'], $extra_class);
      }
    }
   
    else {
      $output .= main_menu_item($link, $data['link']['has_children'], '', $data['link']['in_active_trail'], $extra_class);
    }
  }
  return $output ? main_menu_tree($output) : '';
}



function sub_menu_tree_output($tree) {
  if( isset( $_COOKIE['crystalline_menutype'] ) )
   $this_mtype = $_COOKIE['crystalline_menutype'];
  else
  $this_mtype = theme_get_setting('menutype');
 
  $output = '';
  $items = array();

  // Pull out just the menu items we are going to render so that we
  // get an accurate count for the first/last classes.
  foreach ($tree as $data) {
    if (!$data['link']['hidden']) {
      $items[] = $data;
    }
  }

  $num_items = count($items);
  foreach ($items as $i => $data) {
   
    $extra_class = NULL;
    //$extra_class = get_link_color($items[$i]['title']);
   
    if (stristr($i, 'active')) {
        $extra_class .= " active";
      }
   
   
    if ($i == 0) {
      //$extra_class = 'first';
    }
    if ($i == $num_items - 1) {
      //$extra_class = 'last';
    }
    $link = sub_menu_item_link($data['link'], $data['link']['has_children']);
    if ($data['below']) {
        $extra_class = " parent f-parent-item f-menuparent-item";
        if($this_mtype == "dfission" OR $this_mtype == "suckerfish") {
             $output .= sub_menu_item($link, $data['link']['has_children'], tri_menu_tree_output($data['below']), $data['link']['in_active_trail'], $extra_class);
        }
      else {
         $output .= sub_menu_item($link, $data['link']['has_children'], sub_menu_tree_output($data['below']), $data['link']['in_active_trail'], $extra_class);
        }
    }
    else {
      $output .= sub_menu_item($link, $data['link']['has_children'], '', $data['link']['in_active_trail'], $extra_class);
    }
  }
  return $output ? sub_menu_tree($output) : '';
}

function tri_menu_tree_output($tree) {
  $output = '';
  $items = array();

  // Pull out just the menu items we are going to render so that we
  // get an accurate count for the first/last classes.
  foreach ($tree as $data) {
    if (!$data['link']['hidden']) {
      $items[] = $data;
    }
  }

  $num_items = count($items);
  foreach ($items as $i => $data) {
   
    $extra_class = NULL;
    //$extra_class = get_link_color($items[$i]['title']);
   
    if (stristr($i, 'active')) {
        $extra_class .= " active";
      }
   
    if ($i == 0) {
      //$extra_class = 'first';
    }
    if ($i == $num_items - 1) {
      //$extra_class = 'last';
    }
    $link = tri_menu_item_link($data['link'], $data['link']['has_children']);
    if ($data['below']) {
      $extra_class = " parent ";
      $output .= tri_menu_item($link, $data['link']['has_children'], tri_menu_tree_output($data['below']), $data['link']['in_active_trail'], $extra_class);
    }
    else {
      $output .= tri_menu_item($link, $data['link']['has_children'], '', $data['link']['in_active_trail'], $extra_class);
    }
  }
  return $output ? tri_menu_tree($output) : '';
}





/

* SUB MENU TREE
*/
function sub_menu_tree($tree) {
    $numCols = theme_get_setting('level2cols');
      return '<div class="fusion-submenu-wrapper level2 columns' . $numCols . '"><div class="drop-top"></div><ul class="level2 columns' . $numCols . '">'. $tree .'</ul></div>';
}

/
* TRI MENU TREE
*/
function tri_menu_tree($tree) {
   $numCols = theme_get_setting('level3cols');
      return '<div class="fusion-submenu-wrapper level3 columns' . $numCols . '"><div class="drop-top"></div><ul class="level3 columns' . $numCols . '">'. $tree .'</ul></div>';
}




/

  * MENU ITEM
*/
function main_menu_item($link, $has_children, $menu = '', $in_active_trail = FALSE, $extra_class = NULL) {
  //$class = ($menu ? 'expanded' : ($has_children ? 'collapsed' : 'leaf'));
  $class = "item";
  $id = "";
  if (!empty($extra_class)) {
    $class .= " " . $extra_class;
  }
  if ($in_active_trail) {
    $class .= ' active';
  }
 
  $class .= " root f-main-parent f-mainparent-item";
 
   
  return '<li class="'. $class .'">'. $link . $menu . "</li>\n";
 

}

/
  * SUB MENU ITEM
/
function sub_menu_item($link, $has_children, $menu = '', $in_active_trail = FALSE, $extra_class = NULL) {
  //$class = ($menu ? 'expanded' : ($has_children ? 'collapsed' : 'leaf'));
  $class = "";
  if (!empty($extra_class)) {
    $class .= $extra_class;
  }
  if ($in_active_trail) {
    $class .= ' active';
  }
  return '<li class=" item1'. $class .'">'. $link . $menu . "</li>\n";
}

  /
TRI MENU ITEM
/
function tri_menu_item($link, $has_children, $menu = '', $in_active_trail = FALSE, $extra_class = NULL) {
  //$class = ($menu ? 'expanded' : ($has_children ? 'collapsed' : 'leaf'));
  $class = "";
  if (!empty($extra_class)) {
    $class .= $extra_class;
  }
  if ($in_active_trail) {
    $class .= ' active';
  }
  return '<li class="'. $class .' item1">'. $link . $menu . "</li>\n";
}




function main_menu_item_link($link, $has_children = FALSE) {
  if (empty($link['localized_options'])) {
    $link['localized_options'] = array();
  }
  if(strlen(strstr($link['href'],"http"))>0) {
   $href = $link['href'];   
  }
  else {
      if(variable_get('clean_url', 0)) {
       $href = $link['href'] == "<front>" ? base_path() : base_path() . drupal_get_path_alias($link['href']);
     }
      else {
         $href = $link['href'] == "<front>" ? base_path() : base_path() . "?q=" . drupal_get_path_alias($link['href']);
   }
  }
 
  $subtext = "";//$link['localized_options']['attributes']['title'];
 
  $class = "orphan item bullet";
 
  if($link['title'] == $subtext) {
    $subtext = "";
  }
 
  if($subtext != "" AND theme_get_setting('show_subtext_1')) {
     $class .= " subtext";
  }
 
  if(theme_get_setting('show_subtext_1')) {
   $this_link = "<a class='" . $class . "' href='" . $href . "' title='" . $subtext . "'><span>" . $link['title'] . "<em>" . $subtext . "</em></span></a>";
  }
  else {
      $this_link = "<a class='" . $class . "' href='" . $href . "' title='" . $subtext . "'><span>" . $link['title'] . "</span></a>";
  }
 
  //return l($link['title'], $link['href'], $link['localized_options']);
  return $this_link;
}

function sub_menu_item_link($link, $has_children = FALSE) {
    $user_agent = $_SERVER['HTTP_USER_AGENT'];
    $thisBrowser = _checkBrowser($user_agent);
    $browser_name = $thisBrowser[0];
    $browser_version = $thisBrowser[1];
    $ver = preg_replace ('/.(.
)/','',$browser_version);
    $bname = $browser_name . $ver;

  if (empty($link['localized_options'])) {
    $link['localized_options'] = array();
  }
  if(strlen(strstr($link['href'],"http"))>0) {
      $href = $link['href'];   
  }
  else {
      if(variable_get('clean_url', 0)) {
       $href = $link['href'] == "<front>" ? base_path() : base_path() . drupal_get_path_alias($link['href']);
     }
      else {
         $href = $link['href'] == "<front>" ? base_path() : base_path() . "?q=" . drupal_get_path_alias($link['href']);
   }
  }  
 
  $subtext = "";//$link['localized_options']['attributes']['title'];
 
  if($link['title'] == $subtext) {
   $subtext = "";
  }

  $class = "";
 
  if($subtext != "" AND theme_get_setting('show_subtext_2')) {
   $class .= "subtext ";
  }
 
 
  if($has_children) {
    $class .= "daddy ";
  }
  else {
     $class .= "orphan ";
  }
 
  $class .= "item bullet";
  if($bname == "ie7"){
    $this_link = "<a class='" . $class . "' href='" . $href . "' title='" . $subtext . "'>" . $link['title'] . "</a>";
 
  }
  else {
    if(theme_get_setting('show_subtext_2')) {
       $this_link = "<a class='" . $class . "' href='" . $href . "' title='" . $subtext . "'><span>" . $link['title'] . "<em>" . $subtext . "</em></span></a>";
    }
    else {
      $this_link = "<a class='" . $class . "' href='" . $href . "' title='" . $subtext . "'><span>" . $link['title'] . "</span></a>";
    }
   
  }
  //return l($link['title'], $link['href'], $link['localized_options']);
  return $this_link;
}

function tri_menu_item_link($link, $has_children = FALSE) {
  $user_agent = $_SERVER['HTTP_USER_AGENT'];
    $thisBrowser = _checkBrowser($user_agent);
    $browser_name = $thisBrowser[0];
    $browser_version = $thisBrowser[1];
    $ver = preg_replace ('/.(.*)/','',$browser_version);
    $bname = $browser_name . $ver;

  if (empty($link['localized_options'])) {
    $link['localized_options'] = array();
  }
  if(strlen(strstr($link['href'],"http"))>0) {
    $href = $link['href'];   
  }
  else {
      if(variable_get('clean_url', 0)) {
       $href = $link['href'] == "<front>" ? base_path() : base_path() . drupal_get_path_alias($link['href']);
     }
      else {
         $href = $link['href'] == "<front>" ? base_path() : base_path() . "?q=" . drupal_get_path_alias($link['href']);
   }
  }  
 
  $subtext = $link['localized_options']['attributes']['title'];
 
  if($link['title'] == $subtext) {
      $subtext = "";
  }
 
 
  $class = "";
 
  if($subtext != "" AND theme_get_setting('show_subtext_3')) {
      $class .= "subtext ";
  }
 
  if($has_children) {
   $class .= "daddy ";
  }
  else {
     $class .= "orphan ";
  }
 
  $class .= "item bullet";

  if($bname == "ie7"){
    $this_link = "<a class='" . $class . "' href='" . $href . "' title='" . $subtext . "'>" . $link['title'] . "</a>";

  }
  else {
    if(theme_get_setting('show_subtext_3')) {
        $this_link = "<a class='" . $class . "' href='" . $href . "' title='" . $subtext . "'><span>" . $link['title'] . "<em>" . $subtext . "</em></span></a>";
    }
    else {
      $this_link = "<a class='" . $class . "' href='" . $href . "' title='" . $subtext . "'><span>" . $link['title'] . "</span></a>";
    }
   
  }

  //return l($link['title'], $link['href'], $link['localized_options']);
  return $this_link;
}




//******************************************************************************

//********************************************
// SECONDARY LINK MENU ITEM INFO
//********************************************

/

* Returns a rendered menu tree.
*
* @param $tree
*   A data structure representing the tree as returned from menu_tree_data.
* @return
*   The rendered HTML of that data structure.
*/
function sec_menu_tree_output($tree) {
  $output = '';
  $items = array();

  if( isset( $_COOKIE['crystalline_menu_type'] ) )
    $this_mtype = $_COOKIE['crystalline_menu_type'];
  else
$this_mtype = theme_get_setting('menu_type');
  // Pull out just the menu items we are going to render so that we
  // get an accurate count for the first/last classes.
  foreach ($tree as $data) {
    if (!$data['link']['hidden']) {
      $items[] = $data;
    }
  }

  $num_items = count($items);
  foreach ($items as $i => $data) {
   
    $extra_class = NULL;
    //$extra_class = get_link_color($items[$i]['title']);
   
    if (stristr($i, 'active')) {
        $extra_class .= " active";
      }
   
   
    if ($i == 0) {
      //$extra_class = 'first';
    }
    if ($i == $num_items - 1) {
      //$extra_class = 'last';
    }
    $link = sec_menu_item_link($data['link'], $data['link']['has_children']);
   
    $output .= sec_menu_item($link, $data['link']['has_children'], '', $data['link']['in_active_trail'], $extra_class);
   
  }
  return $output ? sec_menu_tree($output) : '';
}


/
* FULL MENU TREE
*/
function sec_menu_tree($tree) {
     return '<div class="moduletable"><ul id="mainlevel-top">'. $tree .'</ul></div>';
}


/

  * MENU ITEM
*/
function sec_menu_item($link, $has_children, $menu = '', $in_active_trail = FALSE, $extra_class = NULL) {
  //$class = ($menu ? 'expanded' : ($has_children ? 'collapsed' : 'leaf'));
  $class = "item1 png";
  $id = "";
  if (!empty($extra_class)) {
    $class .= " " . $extra_class;
  }
  if ($in_active_trail) {
    $class .= ' active';
    $id .= 'current';
  }
  if($id == ""){
    return '<li class="'. $class .'">'. $link . $menu . "</li>\n";
  }
  else {
    return '<li id="' . $id . '" class="'. $class .'">'. $link . $menu . "</li>\n";
  }
}


function sec_menu_item_link($link, $has_children = FALSE) {
  if (empty($link['localized_options'])) {
    $link['localized_options'] = array();
  }
  if(strlen(strstr($link['href'],"http"))>0) {
   $href = $link['href'];   
  }
  else {
      if(variable_get('clean_url', 0)) {
       $href = $link['href'] == "<front>" ? base_path() : base_path() . drupal_get_path_alias($link['href']);
     }
      else {
         $href = $link['href'] == "<front>" ? base_path() : base_path() . "?q=" . drupal_get_path_alias($link['href']);
   }
  }
 
  $subtext = $link['localized_options']['attributes']['title'];
 
  $this_link = "<a class='mainlevel-top' href='" . $href . "' title='" . $subtext . "'><span class='banner-big'>" . $link['title'] . "</span><span class='banner-small'>" . $subtext . "</span></a>";  
  //return l($link['title'], $link['href'], $link['localized_options']);
  return $this_link;
}



//******************************************************************************


//******************************************************************************

//********************************************
// SPLIT MENU ITEM INFO
//********************************************

/
* Returns a rendered menu tree.
*
* @param $tree
*   A data structure representing the tree as returned from menu_tree_data.
* @return
*   The rendered HTML of that data structure.
*/
function split_menu_tree_output($tree) {
  $output = '';
  $items = array();

  if( isset( $_COOKIE['crystalline_menu_type'] ) )
  $this_mtype = $_COOKIE['crystalline_menu_type'];
  else
$this_mtype = theme_get_setting('menu_type');
  // Pull out just the menu items we are going to render so that we
  // get an accurate count for the first/last classes.
  foreach ($tree as $data) {
    if (!$data['link']['hidden']) {
      $items[] = $data;
    }
  }

  $num_items = count($items);
  foreach ($items as $i => $data) {
   
    $extra_class = NULL;
    //$extra_class = get_link_color($items[$i]['title']);
   
    if (stristr($i, 'active')) {
        $extra_class .= " active";
      }
   
   
    if ($i == 0) {
      //$extra_class = 'first';
    }
    if ($i == $num_items - 1) {
      //$extra_class = 'last';
    }
    $link = split_menu_item_link($data['link'], $data['link']['has_children']);
   
    $output .= split_menu_item($link, $data['link']['has_children'], '', $data['link']['in_active_trail'], $extra_class);
   
  }
  return $output ? split_menu_tree($output) : '';
}


/

* FULL MENU TREE
*/
function split_menu_tree($tree) {
     return '<ul class="menu">'. $tree .'</ul>';
}


/**
  * MENU ITEM
*/
function split_menu_item($link, $has_children, $menu = '', $in_active_trail = FALSE, $extra_class = NULL) {
  //$class = ($menu ? 'expanded' : ($has_children ? 'collapsed' : 'leaf'));
  $class = "";
  $id = "";
  if (!empty($extra_class)) {
    $class .= " " . $extra_class;
  }
  if ($in_active_trail) {
    $class .= 'active';
    $id .= 'current';
  }
  if($id == ""){
   return '<li class="'. $class .'">'. $link . $menu . "</li>\n";
  }
  else {
    return '<li id="' . $id . '" class="'. $class .'">'. $link . $menu . "</li>\n";
  }
}


function split_menu_item_link($link, $has_children = FALSE) {
  if (empty($link['localized_options'])) {
    $link['localized_options'] = array();
  }
  if(strlen(strstr($link['href'],"http"))>0) {
     $href = $link['href'];   
  }
  else {
      if(variable_get('clean_url', 0)) {
       $href = $link['href'] == "<front>" ? base_path() : base_path() . drupal_get_path_alias($link['href']);
     }
      else {
         $href = $link['href'] == "<front>" ? base_path() : base_path() . "?q=" . drupal_get_path_alias($link['href']);
   }
  }
 
  $subtext = $link['localized_options']['attributes']['title'];
 
  $this_link = "<a href='" . $href . "' title='" . $subtext . "'><span>" . $link['title'] . "</span></a>"; 
  //return l($link['title'], $link['href'], $link['localized_options']);
  return $this_link;
}

Comments

$crystalline_menutype

Darko's picture

tl;dr, ali ako vec menjas temu Omega zasto i dalje koristis funkcije iz Crystalline teme?

Ako je sve prebaceno kako treba, poredjenje

if($crystalline_menutype != "none")

nema smisla. Takodje ti koristis funkcije iz stare teme u templete.php

...
  if( isset( $_COOKIE['crystalline_menu_type'] ) )
    $this_mtype = $_COOKIE['crystalline_menu_type'];
  else
...