/** * Override of theme_breadcrumb(). */ function aap_theme_breadcrumb($variables) { $breadcrumb = $variables['breadcrumb']; $page_node = menu_get_object(); $output = '<h2 class="element-invisible">' . t('You are here') . '</h2>'; $output .= '<div class="breadcrumb">' . implode(' <p>></p> ', $breadcrumb); if (!empty($breadcrumb)) { if (!empty($page_node)) { $target = current_path(); $target_text = substr($page_node->title, 0, 50) . '...'; $target_link = l($target_text, drupal_get_path_alias($target)); $content = $page_node->type; $target_content = l($content, drupal_get_path_alias($content)); // $output .= '<p>></p>' . $target_content; $output .= '<p>></p>' . $target_link; } else { $target = current_path(); $path_alias = drupal_get_path_alias($target); $target_link = l(drupal_get_path_alias($target), drupal_get_path_alias($target)); $output .= '<p>></p>' . $target_link; } // Provide a navigational heading to give context for breadcrumb links to // screen-reader users. Make the heading invisible with .element-invisible. $output .= '</div>'; return $output; } }
function thearchivetheme_process_page(&$vars) { $usernav = ''; if (user_is_logged_in()) { global $user; $node = menu_get_object(); $ar = array(); if ($node) { $nid = $node->nid; if (user_access('update collection')) { $ar[] = '<a href="collection/edit/' . $nid . '">編輯</a>'; } if (user_access('update collection')) { $ar[] = '<a href="collection/update/file/' . $nid . '">更新數位檔</a>'; } if (user_access('update collection') && editcol_is_video_collection($nid)) { $ar[] = '<a href="collection/upload/video_icons/' . $nid . '">自定影片圖示</a>'; } if (user_access('delete collection')) { $ar[] = '<a href="collection/delete/' . $nid . '">刪除</a>'; } } if (user_access('control panel')) { $ar[] = '<a href="/control_panel/1">Control Panel</a>'; } $ar[] = 'Login as ' . $user->name; $ar[] = '<a href="/user/logout">Log out</a>'; $usernav = '<div class="row">' . implode(' | ', $ar) . '</div>'; } $vars['usernav'] = $usernav; }
/** * Implements template_preprocess_page. */ function mooc_foundation_access_preprocess_page(&$variables) { // speedreader is enabled if (module_exists('speedreader')) { $variables['speedreader'] = TRUE; } // mespeak is enabled if (module_exists('mespeak')) { $variables['mespeak'] = TRUE; } // support for add child page shortcut $node = menu_get_object(); if ($node && user_access('access printer-friendly version')) { $variables['tabs_extras'][200][] = '<hr>'; $variables['tabs_extras'][200][] = l(t('Print'), 'book/export/html/' . arg(1)); } $child_type = variable_get('book_child_type', 'book'); if ($node && !empty($node->book) && (user_access('add content to books') || user_access('administer book outlines')) && node_access('create', $child_type) && $node->status == 1 && isset($node->book['depth']) && $node->book['depth'] < MENU_MAX_DEPTH) { $variables['tabs_extras'][200][] = '<hr>'; $variables['tabs_extras'][200][] = l(t('Add child page'), 'node/add/' . str_replace('_', '-', $child_type), array('query' => array('parent' => $node->book['mlid']))); } if (user_access('access contextual links')) { $variables['tabs_extras'][0][] = '<li class="cis_accessibility_check"></li>'; } }
/** * Implements hook_css_alter(). */ function cignaGlobal_css_alter(&$vars) { $node = menu_get_object('node'); if (is_object($node) && isset($node->type) && $node->type == 'landing_page') { unset($vars['sites/all/themes/cignaGlobal/css/style.css']); } }
/** * Preprocess for book-navigatoin. * @param array $vars */ function elearning_preprocess_book_navigation(&$vars) { $node = menu_get_object('node'); $vars['prev_title'] = t('Previous'); $vars['next_title'] = t('Next'); $course_items = course_get_items($node); $current_item = $vars['book_link']['nid']; $course_first_item = array_shift(array_keys($course_items)); // if we are on first course_item then do not show the prev_url. if ($course_first_item == $current_item) { $vars['prev_url'] = ''; } // Make sure prev_url is in course_item (to avoid links to unit content_type). $prev_item = book_prev($node->book); $prev_nid = explode('/', $prev_item['link_path']); foreach ($course_items as $key => $type) { if ($key == $current_item) { break; } $prev_course_item = $key; } if (!empty($prev_course_item) && !empty($prev_nid[1]) && $prev_course_item != $prev_nid[1]) { $vars['prev_url'] = url('node/' . $prev_course_item); } if (isset($node->outline_index)) { $vars['node_title'] = '<span class="outline-lesson-prefix">' . t('Lesson @i.', array('@i' => $node->outline_index)) . '</span>' . $node->title; } }
function mvp_preprocess_html(&$vars) { drupal_add_js(drupal_get_path('theme', 'mvp') . '/js/modernizr.min.js', array('scope' => 'header_scripts', 'every_page' => TRUE, 'weight' => 0)); drupal_add_js(drupal_get_path('theme', 'mvp') . '/js/jquery-1.8.2.min.js', array('scope' => 'header', 'group' => JS_LIBRARY, 'every_page' => TRUE, 'weight' => 0)); drupal_add_js(drupal_get_path('theme', 'mvp') . '/js/jquery-ui-1.10.4.min.js', array('scope' => 'header', 'group' => JS_LIBRARY, 'every_page' => TRUE, 'weight' => 3)); if (request_uri() == '/content-dashboard') { drupal_add_js('(function($) { Drupal.behaviors.chosenSelects = { attach: function(context, settings) { $(".views-widget-filter-edit-type select#edit-type").chosen({ width: "200px", placeholder_text_multiple: "Enter in a Content Type" }); $(".views-widget-filter-edit-status-1 select").chosen({ width: "200px", disable_search_threshold: 3 }); } }; })(jQuery);', array('type' => 'inline', 'group' => JS_THEME, 'weight' => 2, 'defer' => TRUE)); } $node = menu_get_object(); if ($node && $node->nid) { $vars['theme_hook_suggestions'][] = 'html__' . $node->type; } }
/** * Implements template_preprocess_page. */ function mooc_foundation_access_preprocess_page(&$variables) { // speedreader is enabled if (module_exists('speedreader')) { $variables['speedreader'] = TRUE; } // mespeak is enabled if (module_exists('mespeak')) { $variables['mespeak'] = TRUE; } // support for add child page shortcut $node = menu_get_object(); if ($node && user_access('access printer-friendly version')) { $variables['tabs_extras'][200][] = '<hr>'; $variables['tabs_extras'][200][] = l(t('Print'), 'book/export/html/' . arg(1)); } $child_type = variable_get('book_child_type', 'book'); if ($node && !empty($node->book) && (user_access('add content to books') || user_access('administer book outlines')) && node_access('create', $child_type) && $node->status == 1 && isset($node->book['depth']) && $node->book['depth'] < MENU_MAX_DEPTH) { $variables['tabs_extras'][200][] = '<hr>'; $variables['tabs_extras'][200][] = l(t('Add child page'), 'node/add/' . str_replace('_', '-', $child_type), array('query' => array('parent' => $node->book['mlid']))); } if (user_access('access contextual links')) { $variables['tabs_extras'][0][] = '<li class="cis_accessibility_check"></li>'; } // remove the prefix that provides a link to the home page // as MOOC is the thing that currently provides support directly for this // and slightly overrides the behavior $keys = array_keys($variables['page']['header']); $keyname = array_shift($keys); unset($variables['page']['header'][$keyname]['#prefix']); }
/** * Overrides the theme_field for field_fb_tags to make it clickable and link to the Event Space (this will change). */ function storyscopezen_field__field_fb_tags($variables) { if ($node = menu_get_object()) { // Get the nid $nid = $node->nid; } $output = ''; $show_all = ''; $path = drupal_lookup_path('alias', current_path()); if (!empty($variables['items'][0])) { $show_all = l('<li class="tags">' . t('Show All') . '</li>', $path, array('html' => 'true', 'attributes' => array('target' => '_self'), 'query' => array('story' => $nid))); $output .= $show_all; } foreach ($variables['items'] as $item) { $fcid = key($item['entity']['field_collection_item']); if (!empty($item['entity']['field_collection_item'][$fcid]['field_mid'][0]['#markup'])) { $mid = $item['entity']['field_collection_item'][$fcid]['field_mid'][0]['#markup']; } if (!empty($item['entity']['field_collection_item'][$fcid]['field_topic'][0]['#markup'])) { $topic = $item['entity']['field_collection_item'][$fcid]['field_topic'][0]['#markup']; } if (!empty($mid) && !empty($topic)) { $id = explode('/', $mid); $lenth = count($id) - 1; $relative_mid = $id[$lenth]; $tags_link = l('<li class="tags">' . $topic . '</li>', $path, array('html' => TRUE, 'attributes' => array('target' => '_self'), 'query' => array('tag' => '/m/' . $relative_mid))); $output .= $tags_link; } elseif (empty($mid) && !empty($topic)) { $output .= '<li class="tags freebase-link">' . $topic . '</li>'; } } // Render the top-level UL. $output = '<ul class="' . $variables['classes'] . '"' . $variables['attributes'] . '>' . $output . '</ul>'; return $output; }
/** * Implements hook_preprocess_HOOK(). */ function badm_preprocess_block(&$variables) { // Add some region/page specifics. $region = $variables['block']->region; if (($node = menu_get_object()) && !arg(2)) { $variables['theme_hook_suggestions'][] = 'block__' . $region . '__' . $node->type; } }
/** * Preprocess functions for page.tpl.php. */ function theadmin_preprocess_page(&$vars) { $node = menu_get_object(); if (isset($node->nid) && $node->type == 'media_gallery') { $node_title = $node->title; $vars['title'] = '<span>edit: </span>' . $node_title; } }
/** * Implementation of preprocess_node(). */ function singular_preprocess_node(&$vars) { $node = menu_get_object(); if ($node === $vars['node']) { $vars['classes_array'][] = 'node-page'; if (!isset($_GET['print'])) { unset($vars['title']); } } }
/** * Implementation of preprocess_node(). */ function hippelicious_preprocess_node(&$vars) { $node = menu_get_object(); if ($node === $vars['node']) { $vars['attr']['class'] .= ' node-page'; if (!isset($_GET['print'])) { unset($vars['title']); } } }
/** * Implements hook_form_alter(). * * Adds the node a webform was submitted from for downloading purposes. * * Bit of functionality in the theme here... but it integrates with the * templates, so putting here seems most logical. */ function centroid_custom_form_alter(&$form, &$form_state, $form_id) { if (strpos($form_id, 'webform_client_form') === 0 && !empty($form['submitted']['referring_nid'])) { if ($node = menu_get_object()) { if (property_exists($node, 'nid')) { $form['submitted']['referring_nid']['#value'] = $node->nid; } } } }
/** * Implements template_preprocess_zone(). */ function dkan_process_zone(&$vars) { if ($vars['zone'] == 'content') { $node = menu_get_object(); $theme = alpha_get_theme(); $tabs = dkan_theme_process_tabs($theme->page['tabs']); $vars['tabs'] = drupal_render($tabs); $vars['action_links'] = drupal_render($theme->page['action_links']); } }
/** * Return Workbench status information in a block. * * To reduce clutter, modules are encouraged to use this hook * to provide debugging and other relevant information. * * @return * An array of message strings to print. The preferred format * is a one line string in the format Title: <em>Message</em>. * @see workbench_block_view(). */ function hook_workbench_block() { // Add editing information to this page (if it's a node). if ($node = menu_get_object()) { if (node_access('update', $node)) { return array(t('My Module: <em>You may not edit this content.</em>')); } else { return array(t('My Module: <em>You may edit this content.</em>')); } } }
function handbuilt_preprocess_region_content_sidebar_left(&$variables) { $top_border = ''; for ($i = 0; $i < 27; $i++) { $top_border .= '<span class="t t-r"></span><span class="t t-l"></span>'; } $variables['content'] = $top_border . $variables['content']; if (_ebr_is_node_page('essay')) { $essay = menu_get_object(); $variables['classes_array'][] = 'thread-' . $essay->thread_name; } }
/** * Implements template_preprocess_html(). */ function bht_theme_preprocess_html(&$variables) { // Define important css classes. $classes_to_keep = array('front', 'page-taxonomy-term'); // Add the node type class to the classes to keep list. $nodetype = preg_grep('/^node-type/', $variables['classes_array']); if ($nodetype) { $type = current($nodetype); $classes_to_keep[$type] = TRUE; } // Strip all CSS classes but and keep the important ones. foreach ($variables['classes_array'] as $key => $class) { if (!in_array($class, $classes_to_keep)) { unset($variables['classes_array'][$key]); } } if (isset($type) && $type == 'node-type-events') { $node = menu_get_object(); if ($node->promote) { $variables['classes_array'][] = 'node-type-events-promote'; } } // Add critical css inline #perfmatters. if (!(bool) variable_get('bht_production', FALSE)) { // Read critical css file contents. $critical_css = file_get_contents(path_to_theme() . '/css/critical.min.css'); // Replace css folder relative paths to site related relative paths. $critical_css = str_replace('../', base_path() . path_to_theme() . '/', $critical_css); drupal_add_css($critical_css, array('type' => 'inline', 'weight' => 1000, 'group' => CSS_THEME)); } // Add the production or development javascript files #perfmatters. if (!(bool) variable_get('bht_production', FALSE)) { drupal_add_js(path_to_theme() . '/js/production.min.js', 'file'); } else { // Remember to alter gruntfile.js to generate a correct production.min.js file. /*drupal_add_js(path_to_theme() . '/js/jquery.colorbox-min.js', 'file');*/ /*drupal_add_js(path_to_theme() . '/js/jquery.fitvids-min.js', 'file');*/ /*drupal_add_js(path_to_theme() . '/js/jquery.scrollto.min.js', 'file');*/ drupal_add_js(path_to_theme() . '/js/scripts.js', 'file'); } // Add theme folder to the variables. $variables['theme_folder'] = base_path() . path_to_theme() . '/'; // Add themePath to drupal settings, cfr. existing basePath. $extra_js_settings = array('themePath' => $variables['theme_folder']); drupal_add_js($extra_js_settings, 'setting'); // Strip out wbr character if (isset($variables['head_title_array']['title'])) { $variables['head_title_array']['title'] = str_replace('||', '', $variables['head_title_array']['title']); } if (isset($variables['head_title'])) { $variables['head_title'] = str_replace('||', '', $variables['head_title']); } }
/** * Implements theme_preprocess_page. * This fixes a bug in top_node where the page title fails to show up. * * @todo * Generalize this fix to respect views page title settings and contribute it * back to the top node project. While we're at it, try and fix that problem * where top_node replaces the $_GET['q'] variable. */ function whaleocalypse_preprocess_page(&$vars) { $node = menu_get_object(); if (is_object($node) && $node->type == 'comic') { $vars['title'] = l($node->title, 'node/' . $node->nid); } if ($vars['logo']) { //pass the site logo through the l() function $logo_image = '<img src="' . $vars['logo'] . '" alt="Home"/>'; $vars['logo'] = l($logo_image, 'main', array("html" => TRUE, "attributes" => array("title" => "Home", "rel" => "home", "id" => "logo"))); } }
function banner_redirect() { $node = menu_get_object(); if ($node && $node->type == 'banner_image') { banner_debug("functions remove line 47"); $node->field_hits['und'][0]['value']++; $node->field_last_accessed['und'][0]['value'] = time(); node_save($node); $data = array('nid' => $node->nid, 'referer' => $_SERVER['HTTP_REFERER'], 'remote' => $_SERVER['REMOTE_ADDR'], 'dest' => $node->field_url['und'][0]['url'], 'time' => time()); hit_stat($data); } }
function radicaldesigns_preprocess_html(&$variables) { //If on an individual node page, add the node type to body classes. if ($node = menu_get_object()) { if (isset($node->body['und'])) { //check if there's a body on this node if (strlen($node->body['und'][0]['value']) > 10) { //check it's got at least ten chars of text $GLOBALS['body_sample'] = substr(strip_tags($node->body['und'][0]['value']), 0, 200); } } } }
/** * Implements hook_preprocess_page(). */ function shelter_preprocess_page(&$variables) { // Put the language switcher in a variable. $block = module_invoke('locale', 'block_view', 'language_content'); $variables['language_switcher'] = $block['content']; global $base_url; $variables['base_url'] = $base_url; $current_path = current_path(); // Adding the viewport for mobile view. $viewport = array('#tag' => 'meta', '#attributes' => array('name' => 'viewport', 'content' => 'width=device-width, initial-scale=1, maximum-scale=1, minimal-ui')); drupal_add_html_head($viewport, 'viewport'); libraries_load('underscore'); drupal_add_library('system', 'jquery.cookie'); $variables['hot_responses'] = FALSE; $variables['is_regions_and_countries'] = FALSE; $variables['is_user_profile_pages'] = FALSE; $variables['is_search_documents'] = FALSE; $variables['global_docs_search_page_link'] = l(t('Search all documents'), 'search-documents', array('attributes' => array('class' => array('search-documents-link')), 'query' => array('sort' => 'date', 'sort_direction' => 'DESC'))); $variables['global_events_page'] = FALSE; $variables['recent_documents'] = FALSE; if ($variables['is_front']) { $variables['hot_responses'] = cluster_og_hot_responses(); $variables['upcoming_events'] = cluster_events_upcoming(); $variables['recent_documents'] = cluster_docs_recent(); } if ($current_path == 'regions-countries') { $variables['is_regions_and_countries'] = TRUE; } if ($current_path == 'search-documents') { $variables['is_search_documents'] = TRUE; $variables['hot_responses'] = cluster_og_hot_responses(); $variables['upcoming_events'] = NULL; } if ($current_path == 'events') { $variables['hot_responses'] = cluster_og_hot_responses(); $variables['global_events_page'] = TRUE; } if (arg(0) == 'user') { $variables['is_user_profile_pages'] = TRUE; } $variables['extra'] = FALSE; if (isset($variables['page']['content']['system_main']['side-column'])) { $variables['extra'] = $variables['page']['content']['system_main']['side-column']; unset($variables['page']['content']['system_main']['side-column']); } elseif ($node = menu_get_object()) { if (isset($variables['page']['content']['system_main']['nodes'][$node->nid][0]['side-column'])) { $variables['extra'] = $variables['page']['content']['system_main']['nodes'][$node->nid][0]['side-column']; unset($variables['page']['content']['system_main']['nodes'][$node->nid][0]['side-column']); } } }
function exploreworld_preprocess_page(&$vars) { $voc = taxonomy_vocabulary_machine_name_load('travel_destinations'); $taxonomy = taxonomy_get_tree($voc->vid); $items = array(); foreach ($taxonomy as $row) { $items[] = $row->name; } $vars['custom_item_list'] = theme('custom_item_list', array('items' => $items)); $obj = menu_get_object(); if (is_object($obj)) { $vars['theme_hook_suggestions'][] = 'page__' . $obj->type; } }
/** * Implements hook_css_alter(). */ function cignaglobal_css_alter(&$css) { $theme_path = drupal_get_path('theme', 'cignaglobal'); // Remove css core and contrib modules. if (!user_is_logged_in()) { foreach ($css as $key => $css_style_info) { if (strpos($key, 'sites/all/modules/contrib') !== FALSE || strpos($key, 'modules/system') !== FALSE || strpos($key, 'modules/field') !== FALSE) { unset($css[$key]); } } } // Remove the overrides.css. $overrides = drupal_get_path('theme', 'bootstrap') . '/css/overrides.css'; if (isset($css[$overrides])) { unset($css[$overrides]); } // Remove bootstrap css from cdn (we still want cdn js). $bootstrap_cdn = theme_get_setting('bootstrap_cdn'); if ($bootstrap_cdn) { // Add CDN. if (theme_get_setting('bootstrap_bootswatch')) { $cdn = '//netdna.bootstrapcdn.com/bootswatch/' . $bootstrap_cdn . '/' . theme_get_setting('bootstrap_bootswatch') . '/bootstrap.min.css'; } else { $cdn = '//netdna.bootstrapcdn.com/bootstrap/' . $bootstrap_cdn . '/css/bootstrap.min.css'; } unset($css[$cdn]); } // Drop styles.min.css and iestyles.min.css if a landing page. $node = menu_get_object('node'); if (is_object($node) && isset($node->type) && $node->type == 'landing_page') { return; } // Temporary method of adding brand awareness landing page styling. $landing_page_urls = function_exists('cigna_lp_menu_keys') ? cigna_lp_menu_keys() : array(); if (in_array(current_path(), $landing_page_urls)) { $style = $theme_path . '/css/landing--brand.min.css'; $css[$style] = array('data' => $style, 'type' => 'file', 'scope' => 'header', 'every_page' => FALSE, 'media' => 'all', 'preprocess' => TRUE, 'group' => CSS_THEME, 'browsers' => array('IE' => TRUE, '!IE' => TRUE), 'weight' => 1000); return; } // Work out if on broker pages. $is_broker_page = is_broker_page(); // Add styles.min.css, else brokerstyle.min.css if on broker pages. $style = !$is_broker_page ? $theme_path . '/css/style.min.css' : $theme_path . '/css/brokerstyle.min.css'; $css[$style] = array('data' => $style, 'type' => 'file', 'scope' => 'header', 'every_page' => FALSE, 'media' => 'all', 'preprocess' => TRUE, 'group' => CSS_THEME, 'browsers' => array('IE' => TRUE, '!IE' => TRUE), 'weight' => 1000); // Add iestyles.min.css. $style = $theme_path . '/css/iestyles.min.css'; $css[$style] = array('data' => $style, 'type' => 'file', 'every_page' => TRUE, 'media' => 'all', 'preprocess' => FALSE, 'group' => CSS_THEME, 'browsers' => array('IE' => TRUE, '!IE' => FALSE), 'weight' => 1001); }
/** * Implements template_preprocess_page. */ function mooc_foundation_access_preprocess_page(&$variables) { // speedreader is enabled if (module_exists('speedreader')) { $variables['speedreader'] = TRUE; } // drop some tabs that don't seem to go away on their own if (isset($variables['tabs']['#primary']) && !empty($variables['tabs']['#primary'])) { foreach ($variables['tabs']['#primary'] as $key => $value) { if (in_array($value['#link']['path'], array('node/%/display', 'node/%/outline', 'node/%/log'))) { unset($variables['tabs']['#primary'][$key]); } } // fornow drop secondary entirely for nodes if (arg(0) == 'node' && isset($variables['tabs']['#secondary'])) { unset($variables['tabs']['#secondary']); } } $child_type = variable_get('book_child_type', 'book'); $node = menu_get_object(); if ($node && !empty($node->book) && (user_access('add content to books') || user_access('administer book outlines')) && node_access('create', $child_type) && $node->status == 1 && isset($node->book['depth']) && $node->book['depth'] < MENU_MAX_DEPTH) { $variables['tabs_extras'][200][] = '<div class="divider"></div>'; $variables['tabs_extras'][200][] = '<span class="nolink cis-lmsless-text">' . t('Operations') . '</strong>'; $variables['tabs_extras'][200][] = l(t('Edit child outline'), 'node/' . $node->book['nid'] . '/outline/children'); $variables['tabs_extras'][200][] = l(t('Edit course outline'), 'admin/content/book/' . $node->book['bid']); } // support hiding the accessibility check UI which is poorly located if ($node && user_access('view accessibility tests')) { $variables['tabs_extras'][200][] = '<span class="cis_accessibility_check"></span>'; } // remove the prefix that provides a link to the home page // as MOOC is the thing that currently provides support directly for this // and slightly overrides the behavior $keys = array_keys($variables['page']['header']); $keyname = array_shift($keys); unset($variables['page']['header'][$keyname]['#prefix']); // Remove title from a page when a gitbook markdown filter is present. if (isset($variables['page']['content']['system_main']['nodes'])) { foreach ($variables['page']['content']['system_main']['nodes'] as $node) { if (isset($node['body']['#object'])) { if ($node['body']['#object']->body['und'][0]['format'] == "git_book_markdown") { $variables['title'] = ""; } } } } }
function eldir_preprocess_html(&$variables, $hook) { $node = menu_get_object(); if (!empty($node)) { $type = $node->type; $variables['classes_array'][] = " node-page"; $variables['classes_array'][] = " ntype-{$type}"; } // Add path-based class for a last line of defense $current_path = current_path(); if (!empty($current_path)) { $variables['classes_array'][] = ' path-' . drupal_html_class(current_path()); } // Add special body class for error pages # if (menu_get_active_item() === 0) { # $variables['body_classes'] .= ' error-page'; # } }
/** * Implements hook_language_switch_links_alter(). */ function eu_projects_theme_language_switch_links_alter(array &$links, $type, $path) { $node = menu_get_object(); $path_explode = explode('/', $path); // Unset lang-switcher links for non-existent translations. if ($node) { $language = $node->language; $translations = translation_node_get_translations($node->tnid); foreach ($links as $langcode => &$link) { $links[$langcode]['attributes']['lang'] = $langcode; $links[$langcode]['attributes']['title'] = $links[$langcode]['title']; if ($language == $langcode) { unset($links[$langcode]); } if (!isset($translations[$langcode])) { unset($links[$langcode]); } } } }
/** * Implements hook_preprocess_page(). * * @see page.tpl.php */ function bootsmacss_preprocess_page(&$variables) { // Extending Drupal.settings with pathToTheme object. drupal_add_js('jQuery.extend(Drupal.settings, { "pathToTheme": "' . path_to_theme() . '" });', 'inline'); // Check whether given page is configured on Display Suite layout. $menu_object = menu_get_object(); if (module_exists('ds') && !empty($menu_object->type)) { $layout = ds_get_layout('node', $menu_object->type, 'full'); } $variables['is_ds_node'] = !empty($layout) ? TRUE : FALSE; // Layout grid logic. if (!$variables['is_ds_node']) { if (empty($variables['page']['sidebar_second'])) { $variables['content_wrapper_classes'] = 'col-sm-8 col-sm-offset-2'; } else { $variables['content_wrapper_classes'] = 'col-sm-8'; } } else { $variables['theme_hook_suggestions'][] = 'page__ds_node'; } }
function edoweb_lbz_preprocess_html(&$variables) { // Add the bundle type of the currently viewed entity $entity = menu_get_object(EDOWEB_ENTITY_TYPE); if ($entity) { $variables['classes_array'][] = "entity-type-{$entity->bundle_type}"; } /** * make google fonts available for themes * uncomment the font you wish to use * */ // Droid font family: a complete family with serif and sans drupal_add_css('https://fonts.googleapis.com/css?family=Droid+Serif|Droid+Sans:400,700&subset=latin,latin-ext', array('type' => 'external')); // Signika font: only serif drupal_add_css('https://fonts.googleapis.com/css?family=Signika:400,600,700,300&subset=latin,latin-ext', array('type' => 'external')); // PT font family: a complete family with serif and sans drupal_add_css('https://fonts.googleapis.com/css?family=PT+Serif|PT+Sans|PT+Sans+Narrow|PT+Sans+Caption&subset=latin,latin-ext', array('type' => 'external')); // Add Font-Awesome drupal_add_css('css/font-awesome.min.css'); }
function main_preprocess_entity(&$variables) { if ($variables['elements']['#bundle'] == "project_image") { $current_path = substr($_SERVER['REQUEST_URI'], 1); $entity_id = $variables['elements']['#entity']->id; $current_delta = 0; $next_delta = 0; $path_arguments = explode('/', $current_path); // Check if 3 arguments are there if (count($path_arguments) == 3) { $node_alias = $path_arguments[0] . "/" . $path_arguments[1]; // Create node path out of the first two arguments to see if it's a node if ($node_path = drupal_lookup_path('source', $node_alias)) { $node = menu_get_object("node", 1, $node_path); // Check if node is of the right type if ($node->type == "project") { // Check if third argument is a number if (is_numeric($path_arguments[2])) { // Load images field $images = field_get_items('node', $node, 'field_project_images'); foreach ($images as $delta => $image) { if ($image['target_id'] == $entity_id) { $current_delta = $delta; break; } } // Check if the next delta is valid // if not, redirect to 1 if (array_key_exists($current_delta + 1, $images)) { $next_delta = $current_delta + 1; } else { $next_delta = 0; } $variables['next_link'] = '/' . $node_alias . '/' . ($next_delta + 1); } } } } } }
/** * Custom breadcrumb generator */ function scc_get_breadcrumb($variables) { $breadcrumbs = drupal_get_breadcrumb(); //$breadcrumbs_copy = $breadcrumbs; //Keep a copy for some usecases $obj = menu_get_object(); /* $path = (empty($obj)) ? $_GET['q'] : drupal_lookup_path('alias', $_GET['q']); $sections = explode("/",$path); $segment = ''; $breadcrumb_mappings = array( //Browse 'index' => 'Browse', ); //Iterate through url sections and generate crumbs based on mappings if(!empty($sections) && !empty($breadcrumb_mappings[$sections[0]])) { $breadcrumbs = array(l('Home','<front>')); $this_path = ""; foreach($sections as $section) { $this_path .= (empty($this_path)) ? $section : "/" . $section; if(!empty($breadcrumb_mappings[$this_path])) { $breadcrumbs[] = l($breadcrumb_mappings[$this_path], $this_path); } } } */ if (!empty($obj) && ($obj->type == 'xf_biomaterial' || $obj->type == 'xf_bioassay')) { $parent = _exframe_get_parent_experiment($obj); $exp_url = drupal_get_path_alias('/node/' . $parent->nid); $breadcrumbs[] = '<a href="' . $exp_url . '">' . $parent->title . '</a>'; } //Add Node title to breadcrumb as it is currently empty if (!empty($obj) && isset($obj->title)) { $breadcrumbs[count($breadcrumbs)] = $obj->title; } return $breadcrumbs; }