Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
njbooher committed Dec 30, 2016
2 parents 3c10974 + a3cb373 commit ac66e60
Showing 1 changed file with 73 additions and 5 deletions.
78 changes: 73 additions & 5 deletions template.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
*/
function suitcase_interim_theme($existing, $type, $theme, $path) {
return array(
'smartmenu_link' => array(
'render element' => 'element',
),
'smartmenu_tree' => array(
'render element' => 'tree',
),
Expand All @@ -38,13 +41,78 @@ function suitcase_interim_form_search_block_form_alter(&$form, &$form_state, $fo

/*
* Implements theme_smartmenu_tree().
*
* Modified version of theme_menu_tree
*
* -------------------------------------------------------------------------
*
* Returns HTML for a wrapper for a menu sub-tree.
*
* @param $variables
* An associative array containing:
* - tree: An HTML string containing the tree's items.
*
* @see template_preprocess_menu_tree()
* @ingroup themeable
*
* -------------------------------------------------------------------------
*
* Modifications:
*
* - Doesn't have a template_preprocess function like theme_menu_tree.
* Instead, the tree variable provided should be the full tree from
* suitcase_interim_smartmenu_tree_output
*
* - Applies attributes (if supplied) to the menu sub-tree
*
* - Does not apply the 'menu' class by default
*
*/
function suitcase_interim_smartmenu_tree($variables) {
if (!empty($variables['tree']['#attributes'])) {
return '<ul' . drupal_attributes($variables['tree']['#attributes']) . '>' . $variables['tree']['#children'] . '</ul>';
$tree = $variables['tree'];
if (!empty($tree['#attributes'])) {
return '<ul' . drupal_attributes($tree['#attributes']) . '>' . $tree['#children'] . '</ul>';
} else {
return '<ul>' . $variables['tree']['#children'] . '</ul>';
return '<ul>' . $tree['#children'] . '</ul>';
}
}


/*
* Implements theme_smartmenu_link().
*
* Modified version of theme_menu_link
*
* -------------------------------------------------------------------------
*
* Returns HTML for a menu link and submenu.
*
* @param $variables
* An associative array containing:
* - element: Structured array data for a menu link.
*
* @ingroup themeable
*
* -------------------------------------------------------------------------
*
* Modifications:
*
* - Only adds the submenu to the output if the link it set to 'Always Show Expanded'
*
*/
function suitcase_interim_smartmenu_link(array $variables) {
$element = $variables['element'];

$output = l($element['#title'], $element['#href'], $element['#localized_options']);

if ($element['#below']) {
$sub_menu = drupal_render($element['#below']);
if ($element['#original_link']['expanded']) {
$output .= $sub_menu;
}
}

return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . "</li>\n";
}

/*
Expand Down Expand Up @@ -138,7 +206,7 @@ function suitcase_interim_smartmenu_tree_output($tree, $attributes = NULL) {
}

// Allow menu-specific theme overrides.
$element['#theme'] = 'menu_link__' . strtr($data['link']['menu_name'], '-', '_');
$element['#theme'] = 'smartmenu_link';
$element['#attributes']['class'] = $class;
$element['#title'] = $data['link']['title'];
$element['#href'] = $data['link']['href'];
Expand Down Expand Up @@ -192,4 +260,4 @@ function suitcase_interim_date_display_range($variables) {

// Add remaining message and return.
return $output . $show_remaining_days;
}
}

0 comments on commit ac66e60

Please sign in to comment.