function template_preprocess_om_maximenu_submenu_links in OM Maximenu 6
Same name and namespace in other branches
- 8 inc/om_maximenu.render.inc \template_preprocess_om_maximenu_submenu_links()
- 7 inc/om_maximenu.render.inc \template_preprocess_om_maximenu_submenu_links()
Process variables for om_maximenu_submenu_links.tpl.php
File
- inc/
om_maximenu.render.inc, line 391 - OM Maximenu Render
Code
function template_preprocess_om_maximenu_submenu_links(&$vars) {
//dsm($vars);
$disabled = $vars['disabled'];
$content = $vars['content'];
// user roles and permissions
$vars['permission'] = om_maximenu_link_visible($vars['content']['roles']);
// php on title
if (isset($content['php_option']) && $content['php_option'] == 1) {
ob_start();
$content['link_title'] = eval($content['link_title']);
//$output = ob_get_contents();
ob_end_clean();
}
// span id
$span_id = !empty($content['id']) ? ' id="' . om_string_name($content['id']) . '"' : '';
// span title
$span_title = !empty($content['description']) && $content['description_option'] == 'hover' ? 'title="' . check_plain($content['description']) . '"' : '';
// link content
$link_option = om_maximenu_link_option($content);
// a link attributes
$attributes = om_maximenu_link_attrib($content);
// link is disabled when it's on its page
$uri = trim($_SERVER['REQUEST_URI']);
$qpath = $_GET['q'];
$path_relative = base_path() . $content['path'];
// Drupal doesn't accept # as valid path on field input
$options = array();
$options['query'] = isset($content['path_query']) ? $content['path_query'] : '';
$options['fragment'] = isset($content['path_fragment']) ? $content['path_fragment'] : '';
// disables link when active
$disable_active_link = $disabled ? $path_relative != $uri && $content['path'] != $qpath ? 1 : 0 : 1;
if (!empty($content['path']) && $disable_active_link) {
$path = $content['path'] == '<front>' ? '' : $content['path'];
// there are too many things inside this $link_options which a regular l() can't handle
//$out .= l($content['link_title'], $content['path'], array('attributes' => $attributes));
$vars['om_link'] = '<a ' . drupal_attributes($attributes) . ' href="' . url($path, $options) . '">' . $link_option . '</a>';
}
elseif (!empty($options['query']) || !empty($options['fragment'])) {
// base path is not necessary when path is empty but anchor is not or query,
$vars['om_link'] = '<a ' . drupal_attributes($attributes) . ' href="' . url('', $options) . '">' . $link_option . '</a>';
}
else {
// title with javascript should have div tag
$script_link = om_string_name($content['link_title'], FALSE);
// title contains some block elements
$link_tag = isset($content['php_option']) && $content['php_option'] == 1 || $script_link == 'Script Link' ? 'div' : 'span';
// useful when you just want a button for getting the content to show and not actually linking to anything
$vars['om_link'] = '<' . $link_tag . $span_id . ' class="' . $attributes['class'] . '" ' . $span_title . '>' . $link_option . '</' . $link_tag . '>';
}
$vars['template_files'][] = 'om-maximenu-submenu-links__' . $vars['maximenu_name'];
$vars['template_files'][] = 'om-maximenu-submenu-links__' . $vars['maximenu_name'] . '-' . $vars['key'];
$vars['template_files'][] = 'om-maximenu-submenu-links__' . om_string_name($content['link_title']);
//dsm($vars);
}