stickynav.module in Sticky Navigation 6
Same filename and directory in other branches
Make a menu or some other element on the page stick on top when you scroll down
File
stickynav.moduleView source
<?php
/**
* @file
* Make a menu or some other element on the page stick on top when you scroll
* down
*/
/**
* Implements hook_init().
*/
function stickynav_init() {
global $user, $theme;
$current_theme = $theme;
if (empty($current_theme)) {
$current_theme = variable_get('theme_default', NULL);
}
// Check if user has an exclusion role.
$excluded_roles = array_filter(variable_get('stickynav-roles-' . $current_theme, array()));
if (array_intersect_key($excluded_roles, $user->roles)) {
return;
}
$selector = variable_get('stickynav-selector-' . $current_theme, '');
// Will only add the sticky nav assets if the theme and selector are set.
if (variable_get('stickynav-enabled-' . $current_theme, FALSE) && trim($selector)) {
drupal_add_css(drupal_get_path('module', 'stickynav') . '/css/stickynav.css');
drupal_add_js(drupal_get_path('module', 'stickynav') . '/js/stickynav.js');
$settings = array(
'stickynav' => array(
'selector' => check_plain($selector),
),
);
drupal_add_js($settings, 'setting');
}
}
/**
* Implements hook_perm().
*/
function stickynav_perm() {
return array(
'administer stickynav',
);
}
/**
* Implements hook_menu().
*/
function stickynav_menu() {
$items['admin/settings/stickynav'] = array(
'title' => 'Sticky Nav Settings',
'description' => 'Settings of sticky navigation on your website',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'stickynav_admin_form',
),
'access callback' => 'user_access',
'access arguments' => array(
'administer stickynav',
),
'file' => 'admin/stickynav.admin.inc',
);
return $items;
}
Functions
Name | Description |
---|---|
stickynav_init | Implements hook_init(). |
stickynav_menu | Implements hook_menu(). |
stickynav_perm | Implements hook_perm(). |