Commit 9006defd authored by Riccardo Padovani's avatar Riccardo Padovani

Removed from footer links with depth >2, added some comments

parent 0ef2cdf7
...@@ -121,30 +121,57 @@ function valencia_preprocess_page( &$vars ) { ...@@ -121,30 +121,57 @@ function valencia_preprocess_page( &$vars ) {
$vars['valencia_footer_menu'] = menu_tree_output($main_menu_tree); $vars['valencia_footer_menu'] = menu_tree_output($main_menu_tree);
} }
/**
* Custom links for footer menu
* Follows http://design.ubuntu.com/web-style-guide/scaffolding#footer
*
* TODO: Remove active class from the link of open page
* This doesn't hurt the layout at the moment, but doesn't follow the
* indications, so can be a problem in the future.
* https://gitlab.com/ubuntu-it-web/valencia/issues/5
*
* TODO: Check if there are > 7 categories, and add footer of type B for
* categories after the 7th
* https://gitlab.com/ubuntu-it-web/valencia/issues/6
*/
function valencia_links__system_main_menu($vars) { function valencia_links__system_main_menu($vars) {
// Var with all HTML of the menu
$html = '<ul>'; $html = '<ul>';
// Counter to select first element of every submenu to add class .first
$voice_number = 0; $voice_number = 0;
foreach ($vars['links'] as $key => $link) { foreach ($vars['links'] as $key => $link) {
// To print every menu voice only one, see Drupal API
if (is_numeric($key)) { if (is_numeric($key)) {
// Store the submenu links
$sub_menu = ''; $sub_menu = '';
$link_title = $link['#title']; $link_title = $link['#title'];
// Check for submenu // Check for submenu, but only if they are of first level!
if (!empty($link['#below'])) { if (!empty($link['#below']) && $link['#original_link']['depth'] === '1') {
// Recurse // If there is a submenu create it using the same function
$sub_menu = theme('links__system_main_menu', array( $sub_menu = theme('links__system_main_menu', array(
'links' => $link['#below'], 'links' => $link['#below'],
)); ));
} }
/**
* We have 3 types of link:
* - First level link, they are h2 title, and will be identify for
* by their depth of 1
* - First link of second level menus, they have class .first,
* identified by $voice_number
* - Others links of second level menus
*/
if ($link['#original_link']['depth'] === '1') { if ($link['#original_link']['depth'] === '1') {
// First level menu is h2 // First level menu is h2
$html .= '<li><h2>' . l($link_title, $link['#href'], array('html' => 'true')) . '</h2>' . $sub_menu . '</li>'; $html .= '<li><h2>' . l($link_title, $link['#href'], array('html' => 'true')) . '</h2>' . $sub_menu . '</li>';
} }
else if ($voice_number === 0) { else if ($voice_number === 0) {
// The first submenu of every menu has class first
$html .= '<li class="first">' . l($link_title, $link['#href'], array('html' => 'true')) . $sub_menu . '</li>'; $html .= '<li class="first">' . l($link_title, $link['#href'], array('html' => 'true')) . $sub_menu . '</li>';
} }
else { else {
// Submenu voice
$html .= '<li>' . l($link_title, $link['#href'], array('html' => 'true')) . $sub_menu . '</li>'; $html .= '<li>' . l($link_title, $link['#href'], array('html' => 'true')) . $sub_menu . '</li>';
} }
$voice_number++; $voice_number++;
...@@ -152,7 +179,6 @@ function valencia_links__system_main_menu($vars) { ...@@ -152,7 +179,6 @@ function valencia_links__system_main_menu($vars) {
} }
$html .= '</ul>'; $html .= '</ul>';
return $html; return $html;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment