4 * Contains all functionality for theming menus.
8 * Implements theme_menu_link().
10 * Hook to recognize external URLs and add class 'external'.
12 function rijkshuisstijl_menu_link($variables) {
13 $link = &$variables['element'];
15 // Unset all the classes.
16 unset($variables['element']['#attributes']['class']);
18 $element = $variables['element'];
21 if ($element['#below']) {
22 $sub_menu = drupal_render($element['#below']);
25 $output = l($element['#title'], $element['#href'], $element['#localized_options']);
26 return '<li' .
drupal_attributes($element['#attributes']) .
'>' .
$output .
$sub_menu .
"</li>\n";
30 * Implements theme_menu_link__menu_block().
32 function rijkshuisstijl_menu_link__menu_block($variables) {
33 $attributes = $variables['element']['#attributes'];
35 $element = $variables['element'];
36 $element['#attributes']['class'] = array();
38 if (in_array('first', $attributes['class'])) {
39 $element['#attributes']['class'][] = 'first-item';
42 if (in_array('active', $attributes['class'])) {
43 $element['#attributes']['class'][] = 'active';
47 if ($element['#below']) {
48 $sub_menu = drupal_render($element['#below']);
49 $element['#attributes']['class'][] = 'open';
51 elseif ($element['#below'] == FALSE
&& in_array('active-trail', $attributes['class'])) {
52 $element['#attributes']['class'][] = 'active';
55 $output = l($element['#title'], $element['#href'], array_merge($element['#localized_options'], array('html' => TRUE
)));
56 return '<li' .
drupal_attributes($element['#attributes']) .
'>' .
$output .
$sub_menu .
"</li>\n";
60 * Implements theme_links().
62 function rijkshuisstijl_links__system_main_menu($variables) {
63 $links = $variables['links'];
64 $attributes = $variables['attributes'];
65 $heading = $variables['heading'];
69 if (count($links) > 0) {
72 // Treat the heading first if it is present to prepend it to the
74 if (!empty($heading)) {
75 if (is_string($heading)) {
76 // Prepare the array that will be used when the passed heading
80 // Set the default level of the heading.
85 $output .
= '<' .
$heading['level'];
86 if (!empty($heading['class'])) {
87 $output .
= drupal_attributes(array('class' => $heading['class']));
90 $output .
= '>' .
check_plain($heading['text']) .
'</' .
$heading['level'] .
'>';
93 $output .
= '<ul' .
drupal_attributes($attributes) .
'>';
95 $num_links = count($links);
98 foreach ($links as
$key => $link) {
101 // Add first, last and active classes to the list of links
102 // to help out themers.
104 $class[] = 'first-item';
107 if ($i == $num_links) {
108 $class[] = 'last-item';
111 if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && drupal_is_front_page())) && (empty($link['language']) || $link['language']->language
== $language_url->language
)) {
115 if (strstr($key, 'active-trail') !== FALSE
&& !in_array('sel', $class)) {
119 $output .
= '<li' .
drupal_attributes(array('class' => $class)) .
'>';
121 if (isset($link['href']) && !empty($link['title'])) {
122 // Pass in $link as $options, they share the same keys.
123 $output .
= l($link['title'], $link['href'], array_merge($link, array('html' => TRUE
)));
125 elseif (!empty($link['title'])) {
126 // Some links are actually not links, but we wrap these in <span>
127 // for adding title and class attributes.
128 if (empty($link['html'])) {
129 $link['title'] = check_plain($link['title']);
132 $span_attributes = '';
133 if (isset($link['attributes'])) {
134 $span_attributes = drupal_attributes($link['attributes']);
137 $output .
= '<span' .
$span_attributes .
'>' .
$link['title'] .
'</span>';
141 $output .
= "</li>\n";
151 * Implements theme_menu_local_tasks().
153 function rijkshuisstijl_menu_local_tasks(&$variables) {
156 if (!empty($variables['primary'])) {
157 // $variables['primary']['#prefix'] = '<h2 class="element-invisible">' . t('Primary tabs') . '</h2>';
158 $variables['primary']['#prefix'] = '<ul class="tabs primary">';
159 $variables['primary']['#suffix'] = '</ul>';
160 $output .
= drupal_render($variables['primary']);
163 if (!empty($variables['secondary'])) {
164 // $variables['secondary']['#prefix'] = '<h2 class="element-invisible">' . t('Secondary tabs') . '</h2>';
165 $variables['secondary']['#prefix'] = '<ul class="tabs secondary">';
166 $variables['secondary']['#suffix'] = '</ul>';
167 $output .
= drupal_render($variables['secondary']);
170 if (drupal_strlen($output) > 0) {
171 $output = '<div class="tabs">' .
$output .
'</div>';