/** * List of methods that assist with handling recording groups. * @package Client * @subpackage PrebuiltForms. */ function group_authorise_form($args, $readAuth) { if (!empty($args['limit_to_group_id']) && $args['limit_to_group_id'] !== (empty($_GET['group_id']) ? '' : $_GET['group_id'])) { // page owned by a different group, so throw them out hostsite_show_message(lang::get('This page is a private recording group page which you cannot access.'), 'alert'); hostsite_goto_page('<front>'); } if (!empty($_GET['group_id'])) { // loading data into a recording group. Are they a member or is the page public? // @todo: consider performance - 2 web services hits required to check permissions. if (hostsite_get_user_field('indicia_user_id')) { $gu = data_entry_helper::get_population_data(array('table' => 'groups_user', 'extraParams' => $readAuth + array('group_id' => $_GET['group_id'], 'user_id' => hostsite_get_user_field('indicia_user_id')), 'nocache' => true)); } else { $gu = array(); } $gp = data_entry_helper::get_population_data(array('table' => 'group_page', 'extraParams' => $readAuth + array('group_id' => $_GET['group_id'], 'path' => drupal_get_path_alias($_GET['q'])))); if (count($gp) === 0) { hostsite_show_message(lang::get('You are trying to access a page which is not available for this group.'), 'alert'); hostsite_goto_page('<front>'); } elseif (count($gu) === 0 && $gp[0]['administrator'] !== NULL) { // not a group member, so throw them out hostsite_show_message(lang::get('You are trying to access a page for a group you do not belong to.'), 'alert'); hostsite_goto_page('<front>'); } } }
/** * Override or insert variables into the page template. */ function rice_preprocess_page(&$vars) { // CSS drupal_add_css(drupal_get_path('theme', 'rice') . '/css/colors.css'); drupal_add_css(drupal_get_path('theme', 'rice') . '/css/columnal.css'); drupal_add_css(drupal_get_path('theme', 'rice') . '/css/custom.css'); drupal_add_css(drupal_get_path('theme', 'rice') . '/css/feed.css'); drupal_add_css(drupal_get_path('theme', 'rice') . '/js/owl-carousel/owl.carousel.css'); drupal_add_css(drupal_get_path('theme', 'rice') . '/js/owl-carousel/owl.transitions.css'); drupal_add_css(drupal_get_path('theme', 'rice') . '/js/owl-carousel/owl.theme.css'); drupal_add_css('https://fonts.googleapis.com/css?family=Cinzel'); // JS drupal_add_js(drupal_get_path('theme', 'rice') . '/js/jquery-1.8.0.min.js'); drupal_add_js(drupal_get_path('theme', 'rice') . '/js/modernizr.js'); drupal_add_js(drupal_get_path('theme', 'rice') . '/js/moment-with-locales.js'); drupal_add_js(drupal_get_path('theme', 'rice') . '/js/tools.js'); drupal_add_js(drupal_get_path('theme', 'rice') . '/js/owl-carousel/owl.carousel.js'); // Condition: Path $match = "<front>"; $path = drupal_get_path_alias($_GET['q']); $path_matches = drupal_match_path($path, $match); if ($path != $_GET['q']) { $path_matches = $path_matches || drupal_match_path($_GET['q'], $matches); } if ($path_matches) { //drupal_add_css(drupal_get_path('theme', 'rice').'/css/style.css'); } //Condition: Role $role = 'anonymous user'; if (in_array($role, $vars['user']->roles)) { //drupal_add_css(drupal_get_path('theme', 'rice').'/anonymous.css'); } }
function ichado1_preprocess_page(&$vars) { $a = 'a'; $cur_path = current_path(); $cur_path_alias = drupal_get_path_alias($cur_path); $add_breadcrumb = drupal_get_title(); if ($cur_path == 'front') { drupal_add_js(drupal_get_path('theme', 'ichado1') . '/js/vktarget.js'); } if ($cur_path == 'cart' || preg_match('/^checkout\\/[\\d]+$/', $cur_path) || preg_match('/^checkout\\/[\\d]+\\/complete$/', $cur_path) || preg_match('/^checkout\\/[\\d]+\\/review$/', $cur_path) || preg_match('/^news$/', $cur_path) || preg_match('/^o-nas$/', $cur_path_alias) || preg_match('/^kontakty$/', $cur_path_alias) || preg_match('/^kak-zakazat-0$/', $cur_path_alias) || preg_match('/^oplata$/', $cur_path_alias) || preg_match('/^dostavka$/', $cur_path_alias) || preg_match('/^garantii-vozvrata$/', $cur_path_alias) || $cur_path == 'user/register' || $cur_path == 'user/login') { $vars['title'] = ''; } if ($cur_path == 'cart' || preg_match('/^checkout\\/[\\d]+$/', $cur_path) || preg_match('/^checkout\\/[\\d]+\\/review$/', $cur_path) || variable_get('auto_scroll', FALSE) || $cur_path == 'catalog' && preg_match('/cart/', $_SERVER['HTTP_REFERER'])) { drupal_add_js(drupal_get_path('theme', 'ichado1') . '/js/auto-scroll.js', 'file'); variable_set('auto_scroll', FALSE); } if (preg_match('/catalog/', $cur_path) || preg_match('/catalog/', $cur_path_alias)) { libraries_load('jcarousel'); } $vars['catalog_menu_drop'] = ''; $context_get = context_get('context'); if ($context_get && in_array('for_drop_down_menu', array_keys($context_get))) { $block = module_invoke('superfish', 'block_view', 1); $catalog_menu_drop = render($block['content']); $vars['catalog_menu_drop'] = $catalog_menu_drop; } /* drupal_add_js('//cdn.callbackhunter.com/cbh.js?hunter_code=7ab9ebf48fe3227cd14cdb9ba43f2cd5', array( 'type' => 'external', 'scope' => 'footer', 'every_page' => TRUE, )); */ }
function stories_for_day($day) { global $s; global $user; $data = $s[1]; $today_events = array(); foreach ($data as $val) { if ($val->field_date_value == $day) { if (isset($today_events[$val->np_nid])) { $today_events[$val->np_nid]['stories'][] = $val; } else { $today_events[$val->np_nid] = array('project_title' => $val->np_title, 'stories' => array($val)); } } } $info = ""; foreach ($today_events as $project_nid => $cell_content) { $info .= "<div class='monthly-schedule-project-item'><strong>" . l($cell_content['project_title'], drupal_get_path_alias("node/" . $project_nid)) . "</strong><ul>"; foreach ($cell_content['stories'] as $story) { $info .= "<li "; if ($story->name != $user->name) { $info .= " class='not-assigned-to-me'"; } $info .= ">" . l("#" . $story->nid, drupal_get_path_alias("node/" . $story->nid)) . " (" . $story->name . ")</li>"; } $info .= "</ul></div>"; } return $info; }
/** * Returns a router item. * * This is a wrapper around menu_get_item() that sets additional keys * (route, link_path, alias, fragments). * * @param $path * The path for which the corresponding router item is returned. * For example, node/5. * * @return array|null * The router item. */ function getRouterItem($path) { $normalpath = drupal_get_normal_path($path); try { $item = menu_get_item($normalpath); } catch (Exception $e) { // Some modules throw an exception, if a path has unloadable arguments. // We don't care, because we don't actually load this page. return NULL; } // Some additional keys. if (empty($item) || !is_array($item)) { return NULL; } // 'route' is a less ambiguous name for a router path than 'path'. $item['route'] = $item['path']; // 'href' sounds more like it had already run through url(). $item['link_path'] = $normalpath; $item['alias'] = drupal_get_path_alias($normalpath); $item['fragments'] = explode('/', $normalpath); if (!isset($item['localized_options'])) { $item['localized_options'] = array(); } if ('crumbs_special_menu_link_page' === $item['page_callback']) { $item['href'] = '<nolink>'; } if ($normalpath !== $item['href']) { $pos = strlen($item['href']); $item['variadic_suffix'] = substr($normalpath, $pos); } else { $item['variadic_suffix'] = NULL; } return $item; }
/** * 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; } }
/** * Implements hook_preprocess_page(). */ function eu_projects_theme_preprocess_page(&$vars, $hook) { $path_alias = drupal_get_path_alias(); // Webtools. $inline_script = '<script defer src="//europa.eu/webtools/load.js" type="text/javascript"></script>'; $element = array('#type' => 'markup', '#markup' => $inline_script); drupal_add_html_head($element, 'webtools'); // Apple-touch-icon-precomposed. $apple_touch_icon_precomposed = array('#tag' => 'link', '#attributes' => array('href' => file_create_url(path_to_theme() . '/images/apple-touch-icon.png'), 'rel' => 'apple-touch-icon-precomposed')); drupal_add_html_head($apple_touch_icon_precomposed, 'apple-touch-icon-precomposed'); // Apple-touch-icon. $apple_touch_icon = array('#tag' => 'link', '#attributes' => array('href' => file_create_url(path_to_theme() . '/images/apple-touch-icon.png'), 'rel' => 'icon')); drupal_add_html_head($apple_touch_icon, 'apple-touch-icon'); // Apple-mobile-web-app-capable. $apple_mobile_web_app_capable = array('#tag' => 'meta', '#attributes' => array('name' => 'apple-mobile-web-app-capable', 'content' => 'yes')); drupal_add_html_head($apple_mobile_web_app_capable, 'apple-mobile-web-app-capable'); // Application-name. $application_name = array('#tag' => 'meta', '#attributes' => array('name' => 'application-name', 'content' => t('EU Results'))); drupal_add_html_head($application_name, 'application-name'); // Apple-mobile-web-app-title. $apple_mobile_web_app_title = array('#tag' => 'meta', '#attributes' => array('name' => 'apple-mobile-web-app-title', 'content' => t('EU Results'))); drupal_add_html_head($apple_mobile_web_app_title, 'apple-mobile-web-app-title'); // Apple-touch-startup-image-ec. $apple_touch_startup_image_ec = array('#tag' => 'meta', '#attributes' => array('rel' => 'apple-touch-startup-image-ec', 'href' => file_create_url(path_to_theme() . '/images/startup-image.png'))); drupal_add_html_head($apple_touch_startup_image_ec, 'apple-touch-startup-image-ec'); // Preload geojson for map if ($path_alias == 'search-projects') { $path = explode('?', request_uri()); $var = isset($path[1]) ? '?' . $path[1] : ''; $preload_geojson = array('#tag' => 'link', '#attributes' => array('rel' => 'prefetch', 'href' => $GLOBALS['base_url'] . '/projects-geojson_' . $GLOBALS['language']->language . $var)); drupal_add_html_head($preload_geojson, 'preload_geojson'); } }
/** * Implements template_preprocess_html(). * * Adds classes to <body> based on path. */ function THEMENAME_preprocess_html(&$vars) { // Get the current path and break it into sections. $parts = explode('/', drupal_get_path_alias()); // Add classes to body based on first section of path. switch ($parts[0]) { case 'path_foo': $vars['classes_array'][] = 'section-foo'; break; case 'path_bar': case 'path_baz': $vars['classes_array'][] = 'section-bar'; break; default: $vars['classes_array'][] = 'section-baz'; break; } // Add classes based on combined first and second section. if (count($parts) >= 2) { switch ($parts[0] . '-' . $parts[1]) { case 'path_foo-list': case 'path_baz-list': $vars['classes_array'][] = 'list-page'; break; } } }
/** * Custom callback to get the URL alias from an article. * * @param DataInterpreterInterface $interpreter * The data interpreter for the current article entity. * * @return string * The URL alias for the article. */ public function getUrlAlias(DataInterpreterInterface $interpreter) { /** @var \EntityDrupalWrapper $wrapper */ $wrapper = $interpreter->getWrapper(); $path = sprintf('node/%d', $wrapper->getIdentifier()); return drupal_get_path_alias($path); }
function boron_preprocess_page(&$vars, $hook) { $body_classes = array($vars['body_classes']); if (!$vars['is_front']) { // Add unique classes for each page and website section $path = drupal_get_path_alias($_GET['q']); list($section, ) = explode('/', $path, 2); list(, $subsection) = explode('/', $path, 3); $body_classes[] = boron_id_safe('page-' . $path); $body_classes[] = boron_id_safe('section-' . $section); $body_classes[] = boron_id_safe('subsection-' . $subsection); if (arg(0) == 'node') { if (arg(1) == 'add') { if ($section == 'node') { array_pop($body_classes); // Remove 'section-node' } $body_classes[] = 'section-node-add'; // Add 'section-node-add' } elseif (is_numeric(arg(1)) && (arg(2) == 'edit' || arg(2) == 'delete')) { if ($section == 'node') { array_pop($body_classes); // Remove 'section-node' } $body_classes[] = 'section-node-' . arg(2); // Add 'section-node-edit' or 'section-node-delete' } } } $vars['body_classes'] = implode(' ', $body_classes); // Concatenate with spaces }
/** * Override or insert PHPTemplate variables into the templates. */ function boldy_preprocess_page(&$vars) { $vars['tabs2'] = menu_secondary_local_tasks(); // Hook into color.module if (module_exists('color')) { _color_page_alter($vars); } // Classes for body element. Allows advanced theming based on context // (home page, node of certain type, etc.) $classes = explode(' ', $vars['body_classes']); // Remove the mostly useless page-ARG0 class. if ($index = array_search(preg_replace('![^abcdefghijklmnopqrstuvwxyz0-9-_]+!s', '', 'page-' . drupal_strtolower(arg(0))), $classes)) { unset($classes[$index]); } if (!$vars['is_front']) { // Add unique class for each page. $path = drupal_get_path_alias($_GET['q']); $classes[] = boldy_id_safe('page-' . $path); // Add unique class for each website section. list($section, ) = explode('/', $path, 2); if (arg(0) == 'node') { if (arg(1) == 'add') { $section = 'node-add'; } elseif (is_numeric(arg(1)) && (arg(2) == 'edit' || arg(2) == 'delete')) { $section = 'node-' . arg(2); } } $classes[] = boldy_id_safe('section-' . $section); } $vars['body_classes_array'] = $classes; $vars['body_classes'] = implode(' ', $classes); // Concatenate with spaces. }
function phptemplate_preprocess_page(&$vars) { $vars['tabs2'] = menu_secondary_local_tasks(); if (module_exists('path')) { $alias = drupal_get_path_alias(str_replace('/edit', '', $_GET['q'])); if ($alias != $_GET['q']) { $suggestions = array(); $template_filename = 'page'; foreach (explode('/', $alias) as $path_part) { $template_filename = $template_filename . '-' . $path_part; $suggestions[] = $template_filename; } $vars['template_files'] = array_merge((array) $suggestions, $vars['template_files']); } } //todo i think this can be deleted if (arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2))) { $termid = arg(2); $parent_term = taxonomy_get_parents($termid); if (key($parent_term) == EMAILS_TERM_ID) { $term = taxonomy_get_term($termid); $vars['template_file'] = 'page-taxonomy-term-emails'; } } }
function sca_responsive_sort_repertoire($results) { // dpm($results); $sorted = array('remarks' => array()); $x = 0; $doubled_entries = array(2425 => 2425, 2427 => 2427); foreach ($results as $entry) { // Views'as kažkodėl dubliuoja visus rezultatus, neturėjau laiko aiškintis kodėl, tad tiesiog atfiltruoju kas antrą. if ($x % 2 !== 0 || in_array($entry->nid, $doubled_entries)) { // $x++; // continue; } // O kai kurie rezultatai (filmų rinkiniai), kažkodėl atrenkami po 4 kartus... if (in_array($entry->node_field_data_field_filmas_nid, $doubled_entries)) { // unset($doubled_entries[$entry->node_field_data_field_filmas_nid]); // $x++; // continue; } $x++; $director = !empty($entry->field_field_motrezisierius) ? $entry->field_field_motrezisierius[0]['rendered']['#markup'] : ''; $director .= !empty($entry->field_field_vyrrezisierius) ? $entry->field_field_vyrrezisierius[0]['rendered']['#markup'] : ''; $director .= !empty($entry->field_field_daugrezisieriu) ? $entry->field_field_daugrezisieriu[0]['rendered']['#markup'] : ''; $sorted[$entry->taxonomy_term_data_field_data_field_vieta_tid][] = array('nid' => $entry->node_field_data_field_filmas_nid, 'entry_nid' => $entry->nid, 'alias' => drupal_get_path_alias('node/' . $entry->node_field_data_field_filmas_nid), 'time' => $entry->field_field_data[0]['rendered']['#markup'], 'small_date' => format_date(strtotime($entry->field_field_data_1[0]['raw']['value']), 'kalendoriaus'), 'title' => $entry->field_title_field[0]['rendered']['#markup'], 'title_lt' => $entry->node_field_data_field_filmas_title, 'title_en' => isset($entry->field_field_engpav[0]) ? $entry->field_field_engpav[0]['rendered']['#markup'] : NULL, 'year' => isset($entry->field_field_metaiirtrukme[0]) ? $entry->field_field_metaiirtrukme[0]['rendered']['#markup'] : NULL, 'country' => !empty($entry->field_field_salis) ? $entry->field_field_salis[0]['rendered']['#markup'] : NULL, 'director' => $director, 'color' => !empty($entry->field_field_programos_spalva) ? $entry->field_field_programos_spalva[0]['rendered']['#markup'] : 'fff', 'extra_text' => !empty($entry->field_field_extra_text) ? $entry->field_field_extra_text[0]['rendered']['#markup'] : NULL, 'program_name' => !empty($entry->field_name_field) ? $entry->field_name_field[0]['rendered']['#markup'] : '', 'remarks' => !empty($entry->field_field_rep_iraso_pastabos) ? $entry->field_field_rep_iraso_pastabos[0]['rendered']['#markup'] : ''); if (!empty($entry->field_field_rep_iraso_pastabos)) { $sorted['remarks'][] = array('time' => $entry->field_field_data_2[0]['rendered']['#markup'], 'place' => $entry->field_field_pilnas_pavadinimas[0]['rendered']['#markup'], 'remark' => $entry->field_field_rep_iraso_pastabos[0]['rendered']['#markup']); } } // dpm($sorted); return $sorted; }
function openfit_base_preprocess_comment(&$variables) { $openfit_node_types = array('activity' => TRUE); if (!isset($variables['node']) || !isset($openfit_node_types[$variables['node']->type])) { return; } $comment = $variables['comment']; // Remove the standard comment links: reply, edit, delete unset($variables['content']['links']['comment']['#links']); // Add a delete menu if the user posted the comment or is admin global $user; if (user_access('administer comments') || $user->uid == $comment->uid) { $url = drupal_get_path_alias('node/' . $variables['node']->nid) . '/comments'; $variables['content']['links']['comment']['#links'] = array('comment-delete' => array('title' => ' ', 'href' => 'comment/' . $comment->cid . '/delete', 'query' => array('destination' => $url), 'html' => TRUE)); } // Display "XX ago" for posts less than 1 day, otherwise use locale to format datetime $ago = time() - $comment->created; if ($ago < 86400) { $variables['created'] = t('!interval ago', array('!interval' => format_interval(time() - $comment->created))); } else { $locale = OpenFitUserSetting::getCurrentUserLocale(); $fmt = new IntlDateFormatter($locale, IntlDateFormatter::SHORT, IntlDateFormatter::SHORT); $created = new DateTime('now'); $created->setTimestamp($comment->created); $variables['created'] = $fmt->format($created); } $variables['submitted'] = $variables['author'] . ' ' . '<time datetime="' . $variables['datetime'] . '" pubdate="pubdate">' . $variables['created'] . '</time>'; }
/** * Preprocessor for page.tpl.php template file. */ function msd15_preprocess_page(&$vars, $hook) { // Get the entire main menu tree $main_menu_tree = menu_tree_all_data('main-menu'); $vars['menu_tree_all_data'] = $main_menu_tree; // Add the rendered output to the $main_menu_expanded variable $vars['main_menu_expanded'] = menu_tree_output($main_menu_tree); if (isset($vars['node']->type)) { // We don't want to apply this on taxonomy or view pages // Splice (2) is based on existing default suggestions. Change it if you need to. array_splice($vars['theme_hook_suggestions'], -1, 0, 'page__' . $vars['node']->type); // Get the url_alias and make each item part of an array $url_alias = drupal_get_path_alias($_GET['q']); $split_url = explode('/', $url_alias); // Add the full path template pages // Insert 2nd to last to allow page--node--[nid] to be last $cumulative_path = ''; foreach ($split_url as $path) { $cumulative_path .= '__' . $path; $path_name = 'page' . $cumulative_path; array_splice($vars['theme_hook_suggestions'], -1, 0, str_replace('-', '_', $path_name)); } // This does just the page name on its own & is considered more specific than the longest path // (because sometimes those get too long) // Also we don't want to do this if there were no paths on the URL // Again, add 2nd to last to preserve page--node--[nid] if we do add it in if (count($split_url) > 1) { $page_name = end($split_url); array_splice($vars['theme_hook_suggestions'], -1, 0, 'page__' . str_replace('-', '_', $page_name)); } } }
static function prepareUrl($path, $params = array(), $requestParams = array(), $customPathParams = array(), $applyPreviousYear = false, $applySpendingYear = false) { $pathParams = explode('/', drupal_get_path_alias($_GET['q'])); $url = $path . _checkbook_append_url_params() . _checkbook_project_get_year_url_param_string($applySpendingYear, $applyPreviousYear); if (is_array($params)) { foreach ($params as $key => $value) { $url .= self::get_url_param($pathParams, $key, $value); } } if (is_array($customPathParams)) { foreach ($customPathParams as $key => $value) { $url .= "/{$key}"; if (isset($value)) { $url .= "/{$value}"; } } } if (is_array($requestParams) && !empty($requestParams)) { $cnt = 0; foreach ($requestParams as $key => $value) { if ($cnt == 0) { $url .= "?{$key}={$value}"; } else { $url .= "&{$key}={$value}"; } $cnt++; } } return $url; }
function aut_preprocess_page(&$vars) { // Add page template suggestions based on the aliased path. For instance, if the current page has an alias of about/history/early, we'll have templates of: // page-about-history-early.tpl.php, page-about-history.tpl.php, page-about.tpl.php // Whichever is found first is the one that will be used. if (module_exists('path')) { $alias = drupal_get_path_alias(str_replace('/edit', '', $_GET['q'])); if ($alias != $_GET['q']) { $template_filename = 'page'; foreach (explode('/', $alias) as $path_part) { $template_filename = $template_filename . '-' . $path_part; $vars['template_files'][] = $template_filename; } } } // Get the entire main menu tree $main_menu_tree = menu_tree_all_data('main-menu'); // Add the rendered output to the $main_menu_expanded variables //$vars['main_menu_expanded'] = menu_tree_output($main_menu_tree); $vars['main_menu_expanded'] = aut_return_menu_markup('main-menu'); // Search Toggle $vars['search'] = FALSE; if (theme_get_setting('toggle_search') && module_exists('search')) { $vars['search'] = drupal_get_form('aut_search_form'); } }
function mothership_preprocess_page(&$vars, $hook) { // Define the content width // Add HTML tag name for title tag. $vars['site_name_element'] = $vars['is_front'] ? 'h1' : 'div'; // Classes for body element. Allows advanced theming based on context // (home page, node of certain type, etc.) $body_classes = array($vars['body_classes']); if (!$vars['is_front']) { // Add unique classes for each page and website section $path = drupal_get_path_alias($_GET['q']); list($section, ) = explode('/', $path, 2); $body_classes[] = mothership_id_safe('page-' . $path); $body_classes[] = mothership_id_safe('section-' . $section); if (arg(0) == 'node') { if (arg(1) == 'add') { if ($section == 'node') { array_pop($body_classes); // Remove 'section-node' } $body_classes[] = 'section-node-add'; // Add 'section-node-add' } elseif (is_numeric(arg(1)) && (arg(2) == 'edit' || arg(2) == 'delete')) { if ($section == 'node') { array_pop($body_classes); // Remove 'section-node' } $body_classes[] = 'section-node-' . arg(2); // Add 'section-node-edit' or 'section-node-delete' } } } $vars['body_classes'] = implode(' ', $body_classes); // Concatenate with spaces }
function hc_bootstrap_preprocess_page(&$variables) { //Set default section to display if (drupal_is_front_page()) { menu_set_active_item('food-and-groceries'); } /** * Add page template suggestions based on the aliased path. For instance, if the current * page has an alias of about/history/early, we'll have templates of: * page-about-history-early.tpl.php, page-about-history.tpl.php, page-about.tpl.php * Whichever is found first is the one that will be used. */ if (module_exists('path')) { $alias = drupal_get_path_alias(str_replace('/edit', '', $_GET['q'])); if ($alias != $_GET['q']) { $template_filename = 'page'; foreach (explode('/', $alias) as $path_part) { $template_filename = $template_filename . '-' . $path_part; $vars['template_files'][] = $template_filename; } } } //Add shopping cart to available output $variables['side_cart'] = block_render('views', 'sidebar_cart-cart'); }
function danbury_preprocess_html(&$variables) { $path = drupal_get_path_alias($_GET['q']); $aliases = explode('/', $path); foreach ($aliases as $alias) { $variables['classes_array'][] = 'path-' . drupal_clean_css_identifier($alias); } }
/** * Allows to override activation of Colobox for the current URL. * * @param $active * A boolean indicating whether colorbox should be active for the current * URL or not. */ function hook_colorbox_active_alter(&$active) { $path = drupal_get_path_alias($_GET['q']); if (drupal_match_path($path, 'admin/config/colorbox_test')) { // Enable colorbox for this URL. $active = TRUE; } }
function masthead_preprocess_html(&$vars) { $path = drupal_get_path_alias($_GET['q']); $aliases = explode('/', $path); foreach ($aliases as $alias) { $vars['classes_array'][] = drupal_clean_css_identifier($alias); } }
function swv_preprocess_html(&$variables, $hook) { $path = drupal_get_path_alias($_GET['q']); $arraypath = explode('/', $path); if (count($arraypath) > 0) { $variables['html_attributes_array'] = array('class' => $arraypath[0]); } }
/** * @file * template.php */ function corporatex3_preprocess_page(&$vars) { $path = drupal_get_path_alias(); if ($path == 'contact') { $vars['title'] = t('Contact us'); drupal_set_title(t('Contact us')); } }
static function generateWidgetGridViewLink($node) { if (empty($node->data) || $node->disableGridViewLink) { return '<a class="chart-grid-view no-data" style="display:none" oncontextmenu="return false;">Grid View</a>'; } return '<a class="chart-grid-view gridpopup" style="display:none" href="/gridview/popup/widget/' . $node->nid . '?refURL=' . check_plain(drupal_get_path_alias($_GET['q'])) . '">Grid View</a>'; }
/** * Implements template_preprocess_html(). */ function theme866_preprocess_html(&$vars) { $vars['doctype'] = _theme866_doctype(); $vars['rdf'] = _theme866_rdf($vars); // Since menu is rendered in preprocess_page we need to detect it here to add body classes $has_main_menu = theme_get_setting('toggle_main_menu'); $has_secondary_menu = theme_get_setting('toggle_secondary_menu'); /* Add extra classes to body for more flexible theming */ if ($has_main_menu or $has_secondary_menu) { $vars['classes_array'][] = 'with-navigation'; } if ($has_secondary_menu) { $vars['classes_array'][] = 'with-subnav'; } if (!empty($vars['page']['featured'])) { $vars['classes_array'][] = 'featured'; } if (!empty($vars['page']['triptych_first']) || !empty($vars['page']['triptych_middle']) || !empty($vars['page']['triptych_last'])) { $vars['classes_array'][] = 'triptych'; } if (!empty($vars['page']['footer_firstcolumn']) || !empty($vars['page']['footer_secondcolumn']) || !empty($vars['page']['footer_thirdcolumn']) || !empty($vars['page']['footer_fourthcolumn'])) { $vars['classes_array'][] = 'footer-columns'; } if ($vars['is_admin']) { $vars['classes_array'][] = 'admin'; } if (!$vars['is_front']) { // Add unique classes for each page and website section $path = drupal_get_path_alias($_GET['q']); $temp = explode('/', $path, 2); $section = array_shift($temp); $page_name = array_shift($temp); if (isset($page_name)) { $vars['classes_array'][] = theme866_id_safe('page-' . $page_name); } $vars['classes_array'][] = theme866_id_safe('section-' . $section); // add template suggestions $vars['theme_hook_suggestions'][] = "page__section__" . $section; $vars['theme_hook_suggestions'][] = "page__" . $page_name; if (arg(0) == 'node') { if (arg(1) == 'add') { if ($section == 'node') { array_pop($vars['classes_array']); // Remove 'section-node' } $body_classes[] = 'section-node-add'; // Add 'section-node-add' } elseif (is_numeric(arg(1)) && (arg(2) == 'edit' || arg(2) == 'delete')) { if ($section == 'node') { array_pop($vars['classes_array']); // Remove 'section-node' } $body_classes[] = 'section-node-' . arg(2); // Add 'section-node-edit' or 'section-node-delete' } } } }
/** HTML.TPL.PHP PREPROCESS VARIABLES ---------------------------------------------------------- */ function megatron_preprocess_html(&$vars) { // Classes for body element. Allows advanced theming based on context // (home page, node of certain type, etc.) if (!$vars['is_front']) { // Add unique class for each page. $path = drupal_get_path_alias($_GET['q']); // Add unique class for each website section. list($section, ) = explode('/', $path, 2); if (arg(0) == 'node') { if (arg(1) == 'add') { $section = 'node-add'; } elseif (is_numeric(arg(1)) && (arg(2) == 'edit' || arg(2) == 'delete')) { $section = 'node-' . arg(2); } } // add a body class that reflects content placement $vars['classes_array'][] = drupal_html_class('section-' . megatron_id_safe($section)); $vars['classes_array'][] = drupal_html_class('path-' . megatron_id_safe($path)); } // add a body class to tell us what layout we're using //$vars['classes_array'][] = drupal_html_class('layout' . theme_get_setting('clf_layout')); // add a body class to tell us what colours we're using $vars['classes_array'][] = drupal_html_class('themecolour' . theme_get_setting('clf_clf_theme_new')); //Uses RDFa attributes if the RDF module is enabled //Lifted from Adaptivetheme for D7, full credit to Jeff Burnz // Add rdf info $vars['doctype'] = '<!DOCTYPE html>' . "\n"; $vars['rdf'] = new stdClass(); $vars['rdf']->version = ''; $vars['rdf']->namespaces = ''; $vars['rdf']->profile = ''; if (module_exists('rdf')) { $vars['doctype'] = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML+RDFa 1.1//EN">' . "\n"; $vars['rdf']->version = 'version="HTML+RDFa 1.1"'; $vars['rdf']->namespaces = $vars['rdf_namespaces']; $vars['rdf']->profile = ' profile="' . $vars['grddl_profile'] . '"'; } // Add js libraries and scripts $clfVerison = theme_get_setting('clf_clf_version'); $options = array('group' => JS_THEME); drupal_add_js('//cdn.ubc.ca/clf/' . $clfVerison . '/js/ubc-clf.min.js', array('type' => 'external', 'group' => JS_LIBRARY, 'weight' => 0)); // Add CSS if layout is not default $clfLayout = theme_get_setting('clf_layout'); //if (!empty($clfLayout)) { if ($clfLayout == '__full' || $clfLayout == '__fluid') { $vars['classes_array'][] = drupal_html_class('full-width'); } if ($clfLayout == '__fluid') { $vars['classes_array'][] = drupal_html_class('full-width-left'); } /*if ($clfLayout == '__fluid') { drupal_add_css(drupal_get_path('theme','megatron') . '/css/fluid-width.css', array('group' => CSS_THEME, 'every_page' => TRUE)); } if ($clfLayout == '__full') { drupal_add_css(drupal_get_path('theme','megatron') . '/css/full-width.css', array('group' => CSS_THEME, 'every_page' => TRUE)); }*/ }
/** * Implements hook_preprocess_page */ function osha_admin_preprocess_page(&$variables) { // MC-123 Open all languages with one click if (isset($variables['node'])) { $node = $variables['node']; drupal_add_js(array('osha' => array('node_nid' => $node->nid, 'node_translations' => array_keys($node->translations->data), 'is_publication_node' => $node->type == 'publication', 'path_alias' => drupal_get_path_alias('node/' . $node->nid))), array('type' => 'setting')); drupal_add_js(drupal_get_path('module', 'osha') . '/js/open_all_translations.js'); } }
function previous_page_link($node) { $next_nid = db_query("\n\t\tSELECT nid FROM {node}\n\t\tWHERE created < :created AND type = :type AND status = 1\n\t\tORDER BY created DESC\n\t\tLIMIT 1", array(':created' => $node->created, ':type' => $node->type))->fetchObject(); if ($next_nid) { return '/' . drupal_get_path_alias('node/' . $next_nid->nid); } else { return false; } }
/** * Implementation of hook_page_alter() */ function andromeda_page_alter(&$page) { //match pages and unset sidebar on matched pages $pages = drupal_strtolower(theme_get_setting('andromeda_sidebar_visibility')); $path = drupal_strtolower(drupal_get_path_alias($_GET['q'])); if (drupal_match_path($path, $pages)) { unset($page['sidebar']); } }