/** * Implemements hook_process_page * @param array $variables */ function fs_core_preprocess_page(&$variables) { //Search form $search_form = drupal_get_form('search_form'); $search_form_box = drupal_render($search_form); $variables['search_box'] = $search_form_box; if ($views_page = views_get_page_view()) { $variables['theme_hook_suggestions'][] = 'page__views__' . $views_page->name; $variables['theme_hook_suggestions'][] = 'page__views__' . $views_page->name . '_' . $views_page->current_display; } if (isset($variables['node']->type)) { $variables['theme_hook_suggestions'][] = 'page__' . $variables['node']->type; } // changes the links tree for the main menu, since by // default Drupal just provides first level ones $menu_tree = menu_tree_all_data('main-menu'); $menu_tree = menu_tree_output($menu_tree); foreach ($menu_tree as $k => $v) { if (is_numeric($k) && count($v['#below'])) { $menu_tree[$k]['#below']['#theme_wrappers'][0] = 'menu_tree__submenu'; } } $variables['main_menu'] = $menu_tree; if (arg(0) == 'taxonomy' && arg(1) == 'term') { $tid = (int) arg(2); $term = taxonomy_term_load($tid); if (is_object($term)) { $variables['theme_hook_suggestions'][] = 'page__taxonomy__' . $term->vocabulary_machine_name; } } }
/** * Preprocessor for theme('page'). */ function rubik_preprocess_page(&$vars) { // Show a warning if base theme is not present. if (!function_exists('tao_theme') && user_access('administer site configuration')) { drupal_set_message(t('The Rubik theme requires the !tao base theme in order to work properly.', array('!tao' => l('Tao', 'http://code.developmentseed.org/tao'))), 'warning'); } rubik_removetab('Workflow', $vars); // Split page content & content blocks. $vars['content_region'] = theme('blocks_content', TRUE); // Set a page icon class. $vars['page_icon_class'] = ($item = menu_get_item()) ? _rubik_icon_classes($item['href']) : ''; // Add body class for theme. $vars['attr']['class'] .= ' rubik'; // Body class for admin module. $vars['attr']['class'] .= ' admin-static'; // Help pages. They really do need help. if (strpos($_GET['q'], 'admin/help/') === 0) { $vars['content'] = theme('help_page', $vars['content']); } // Display user account links. $vars['user_links'] = _rubik_user_links(); // Help text toggler link. $vars['help_toggler'] = l(t('Help'), $_GET['q'], array('attributes' => array('id' => 'help-toggler', 'class' => 'toggler'), 'fragment' => 'help-text')); // Clear out help text if empty. if (empty($vars['help']) || !strip_tags($vars['help'])) { $vars['help'] = ''; } $view = views_get_page_view(); if ($view->name == 'VRM_all_feedback_list') { global $theme; //drupal_add_js(drupal_get_path('theme', $theme) . 'tcal.js', 'theme', 'footer', FALSE, TRUE, FALSE); } }
function storvargen_preprocess_page(&$variables) { $view = views_get_page_view(); if (isset($view)) { // If the content type's machine name is "my_machine_name" the file // name will be "page--my-machine-name.tpl.php". $variables['theme_hook_suggestions'][] = 'page__view'; } if (isset($variables['node']->type)) { // If the content type's machine name is "my_machine_name" the file // name will be "page--my-machine-name.tpl.php". $variables['theme_hook_suggestions'][] = 'page__' . $variables['node']->type; } }
/** * Implements \Drupal\block\BlockBase::build(). */ public function build() { if (!($view = views_get_page_view())) { return; } $style = $view->display_handler->getOption('style'); if ($style['type'] != 'fullcalendar') { return; } $fields = array(); foreach ($view->field as $field) { if (fullcalendar_field_is_date($field)) { $fields[$field->field_info['field_name']] = $field->field_info; } } return array('#theme' => 'fullcalendar_legend', '#types' => $this->buildLegend($fields)); }
/** * Implements hook_preprocess_page(). */ function grapes_preprocess_page(&$vars, $hook) { //drupal_add_js(drupal_get_path('theme', 'grapes') . '/js/script.js'); $variables['title_attributes_array']['class'][] = 'page__title'; $variables['title_attributes_array']['id'] = 'page-title'; // Hide titles of some Views if (module_exists('views') && ($view = views_get_page_view())) { $views_hide_title = array('products_grapes : page' => TRUE); $view_key = $view->name . ' : ' . $view->current_display; if (isset($views_hide_title[$view_key])) { if ($views_hide_title[$view_key]) { $vars['title_attributes_array']['class'][] = 'element-invisible'; } else { $vars['title'] = FALSE; } } } }
function manis_preprocess_page(&$vars) { if (isset($vars['node'])) { $vars['theme_hook_suggestions'][] = 'page__' . $vars['node']->type; } //404 page $status = drupal_get_http_header("status"); if ($status == "404 Not Found") { $vars['theme_hook_suggestions'][] = 'page__404'; } //Taxonomy page if (arg(0) == 'taxonomy') { $vars['theme_hook_suggestions'][] = 'page__taxonomy'; } //View template if (views_get_page_view()) { $vars['theme_hook_suggestions'][] = 'page__view'; } drupal_add_js('jQuery.extend(Drupal.settings, { "pathToTheme": "' . base_path() . path_to_theme() . '" });', 'inline'); }
/** * {@inheritdoc} */ public function getArgument() { // If there is a user object in the current route. if ($this->view->getRequest()->attributes->has('user')) { $user = $this->view->getRequest()->attributes->get('user'); if ($user instanceof UserInterface) { return $user->id(); } } // If option to use node author; and node in current route. if (!empty($this->options['user']) && $this->view->getRequest()->attributes->has('node')) { $node = $this->view->getRequest()->attributes->get('node'); if ($node instanceof NodeInterface) { return $node->getOwnerId(); } } // If the current page is a view that takes uid as an argument. $view = views_get_page_view(); if ($view && isset($view->argument['uid'])) { return $view->argument['uid']->argument; } }
function theme_preprocess_page(&$variables) { $status = drupal_get_http_header("status"); if ($status == "404 Not Found") { $variables['theme_hook_suggestions'][] = 'page__404'; } if ($status == "403 Forbidden") { $variables['theme_hook_suggestions'][] = 'page__403'; } if (arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2))) { unset($variables['page']['content']['system_main']['term_heading']['#prefix']); unset($variables['page']['content']['system_main']['term_heading']['#suffix']); } //if(isset($variables['node']) && $variables['node']->type == "your_content_type") { //drupal_set_title("my_title"); //} $variables['page']['titleclass'] = 'title__about'; //dpm($variables); if (isset($variables['node'])) { if (isset($variables['node']->field_descr)) { $field_descr = field_get_items('node', $variables['node'], 'field_descr'); $variables['page']['descr'] = field_view_value('node', $variables['node'], 'field_descr', $field_descr[0]); } if ($variables['node']->type == 'info') { $variables['page']['titleclass'] = 'title__info'; $voc = taxonomy_vocabulary_load(5); if (isset($voc->field_descr)) { $field_descr = field_get_items('taxonomy_vocabulary', $voc, 'field_descr'); $variables['page']['descr'] = field_view_value('taxonomy_vocabulary', $voc, 'field_descr', $field_descr[0]); } } } else { if (arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2))) { $variables['page']['titleclass'] = 'title__tarifs'; } else { if (function_exists('views_get_page_view') && views_get_page_view()) { $view = views_get_page_view(); //dpm($view); if ($view->name == 'tarifs') { $variables['page']['titleclass'] = 'title__tarifs'; $voc = taxonomy_vocabulary_load(2); if (isset($voc->field_descr)) { $field_descr = field_get_items('taxonomy_vocabulary', $voc, 'field_descr'); $variables['page']['descr'] = field_view_value('taxonomy_vocabulary', $voc, 'field_descr', $field_descr[0]); } } else { if ($view->name == 'info') { $variables['page']['titleclass'] = 'title__info'; $voc = taxonomy_vocabulary_load(5); if (isset($voc->field_descr)) { $field_descr = field_get_items('taxonomy_vocabulary', $voc, 'field_descr'); $variables['page']['descr'] = field_view_value('taxonomy_vocabulary', $voc, 'field_descr', $field_descr[0]); } } else { if ($view->name == 'contacts') { $variables['page']['titleclass'] = 'title__contact'; $voc = taxonomy_vocabulary_load(3); if (isset($voc->field_descr)) { $field_descr = field_get_items('taxonomy_vocabulary', $voc, 'field_descr'); $variables['page']['descr'] = field_view_value('taxonomy_vocabulary', $voc, 'field_descr', $field_descr[0]); } } else { if ($view->name == 'price') { $variables['page']['titleclass'] = 'title__price'; $voc = taxonomy_vocabulary_load(4); if (isset($voc->field_descr)) { $field_descr = field_get_items('taxonomy_vocabulary', $voc, 'field_descr'); $variables['page']['descr'] = field_view_value('taxonomy_vocabulary', $voc, 'field_descr', $field_descr[0]); } } } } } } } } }
function negd_preprocess_page(&$variables, $hook) { if (isset($variables['node'])) { $type = $variables['node']->type; if ($type == 't_owner_assignments') { $title = $variables['node']->field_task_title ? $variables['node']->field_task_title['und'][0]['value'] : ''; $variables['title'] = $title; $variables['theme_hook_suggestions'][] = 'page__t_owner_assignments'; // Added by akv $variables['interested_link'] = _is_interested(arg(1)); // akv $variables['node_content'] =& $variables['page']['content']['system_main']['nodes'][arg(1)]; // akv } } $main_menu_tree = menu_tree_all_data('menu-left-menu'); if (($views_page = views_get_page_view()) && $views_page->name === "calendar") { $variables['theme_hook_suggestions'][] = 'page__views__calendar'; } negd_removetab($variables); }
/** * {@inheritdoc} */ public function getArgument() { // Load default argument from taxonomy page. if (!empty($this->options['term_page'])) { if (($taxonomy_term = $this->routeMatch->getParameter('taxonomy_term')) && $taxonomy_term instanceof TermInterface) { return $taxonomy_term->id(); } } // Load default argument from node. if (!empty($this->options['node'])) { // Just check, if a node could be detected. if (($node = $this->routeMatch->getParameter('node')) && $node instanceof NodeInterface) { $taxonomy = array(); foreach ($node->getFieldDefinitions() as $field) { if ($field->getType() == 'taxonomy_term_reference') { foreach ($node->get($field->getName()) as $item) { $allowed_values = $field->getSetting('allowed_values'); $taxonomy[$item->target_id] = $allowed_values[0]['vocabulary']; } } } if (!empty($this->options['limit'])) { $tids = array(); // filter by vocabulary foreach ($taxonomy as $tid => $vocab) { if (!empty($this->options['vids'][$vocab])) { $tids[] = $tid; } } return implode($this->options['anyall'], $tids); } else { return implode($this->options['anyall'], array_keys($taxonomy)); } } } // If the current page is a view that takes tid as an argument, // find the tid argument and return it. $views_page = views_get_page_view(); if ($views_page && isset($views_page->argument['tid'])) { return $views_page->argument['tid']->argument; } }
/** * Override or insert variables into the page templates. * * @param $variables * An array of variables to pass to the theme template. * @param $hook * The name of the template being rendered ("page" in this case.) */ function vizz2_preprocess_page(&$vars, $hook) { if (!empty($vars['node'])) { $vars['theme_hook_suggestions'][] = 'page__node__' . $vars['node']->type; // $vars['theme_hook_suggestions'][] = 'taxonomy_term__' . $term->vocabulary_machine_name; // $vars['theme_hook_suggestions'][] = 'taxonomy_term__' . $term->tid; } // whoever decided to separate deep leve styles based on the <body> class?! :-@ if (views_get_page_view()) { $vars['theme_hook_suggestions'][] = 'page__view__newsarticles'; $vars['theme_hook_suggestions'][] = 'page__view__datausearticles'; $vars['theme_hook_suggestions'][] = 'page__view__viewallevents'; } if (isset($vars['page']['content']['system_main']['no_content'])) { unset($vars['page']['content']['system_main']['no_content']); } $status = drupal_get_http_header("status"); if ($status == "404 Not Found") { $vars['theme_hook_suggestions'][] = 'page__404'; } if ($status == "403 Forbidden") { $vars['theme_hook_suggestions'][] = 'page__403'; } if ($GLOBALS['pager_total_items']) { // attempt to cheat the number of nodes in a taxonomy page. // search.module shows 10 items per page (this isn't customizable) $itemsPerPage = 10; // Determine which page is being viewed // If $_REQUEST['page'] is not set, we are on page 1 $currentPage = (isset($_REQUEST['page']) ? $_REQUEST['page'] : 0) + 1; // Get the total number of results from the global pager $total = $GLOBALS['pager_total_items'][0]; // Determine which results are being shown ("Showing results x through y") $start = 10 * $currentPage - 9; // If on the last page, only go up to $total, not the total that COULD be // shown on the page. This prevents things like "Displaying 11-20 of 17". $end = $itemsPerPage * $currentPage >= $total ? $total : $itemsPerPage * $currentPage; // If there is more than one page of results: if ($total > $itemsPerPage) { $vars['search_totals'] = t('Displaying !start - !end of !total results', array('!start' => $start, '!end' => $end, '!total' => $total)); } else { // Only one page of results, so make it simpler $vars['search_totals'] = t('Displaying !total !results_label', array('!total' => $total, '!results_label' => format_plural($total, 'result', 'results'))); } } // echo '<pre>'; var_dump($vars['theme_hook_suggestions']); echo '</pre>'; // Getting the search term from the search form. if (!empty($vars['page']['content']['system_main']['search_form']['basic']['keys']['#default_value'])) { $term = trim(check_plain($vars['page']['content']['system_main']['search_form']['basic']['keys']['#default_value'])); $GLOBALS['searchString'] = $term; $country = reset(taxonomy_get_term_by_name($term, 'countries')); if (!empty($country)) { $GLOBALS['is_country'] = TRUE; $GLOBALS['country_iso2'] = $country->field_iso2['und'][0]['value']; } } }
function negd_preprocess_page(&$variables, $hook) { if (isset($variables['node'])) { $type = $variables['node']->type; if ($type == 't_owner_assignments') { $title = $variables['node']->field_task_title ? $variables['node']->field_task_title['und'][0]['value'] : ''; $variables['title'] = $title; } } $main_menu_tree = menu_tree_all_data('menu-left-menu'); if (($views_page = views_get_page_view()) && $views_page->name === "calendar") { $variables['theme_hook_suggestions'][] = 'page__views__calendar'; } negd_removetab($variables); }
/** * Custom function that returns the group node of the current group context. */ function unl_fourone_og_get_current_group() { if (module_exists('og_context')) { $group_context = og_context(); $view = views_get_page_view(); // Set the og context if we are viewing a Views Page display with one of the // contextual filters (in the switch) combined with an "OG membership" relationship. if (empty($group_context) && ($view = views_get_page_view())) { if ($view->display_handler->plugin_name == 'page') { foreach ($view->argument as $key => $value) { switch ($key) { case 'gid': og_context('node', node_load($view->argument['gid']->argument)); $group_context = og_context(); break; case 'title': $query = new EntityFieldQuery(); $entities = $query->entityCondition('entity_type', 'node')->propertyCondition('title', $view->argument['title']->argument)->propertyCondition('status', 1)->range(0, 1)->execute(); if (!empty($entities['node'])) { $keys = array_keys($entities['node']); og_context('node', node_load(array_shift($keys))); $group_context = og_context(); } break; // This is a hack using a field with the specific name 'field_url_path' because // relying on path alias does not work: https://drupal.org/node/1658352#comment-7927861 // This is a hack using a field with the specific name 'field_url_path' because // relying on path alias does not work: https://drupal.org/node/1658352#comment-7927861 case 'field_url_path_value': $query = new EntityFieldQuery(); $entities = $query->entityCondition('entity_type', 'node')->fieldCondition('field_url_path', 'value', $view->argument['field_url_path_value']->argument)->propertyCondition('status', 1)->range(0, 1)->execute(); if (!empty($entities['node'])) { $keys = array_keys($entities['node']); og_context('node', node_load(array_shift($keys))); $group_context = og_context(); } break; } } } } if ($group_context) { return node_load($group_context['gid']); } } return false; }
* - $page['highlighted']: Items for the highlighted content region. * - $page['content']: The main content of the current page. * - $page['sidebar_first']: Items for the first sidebar. * - $page['sidebar_second']: Items for the second sidebar. * - $page['header']: Items for the header region. * - $page['footer']: Items for the footer region. * * @see template_preprocess() * @see template_preprocess_page() * @see template_process() * @see html.tpl.php * * @ingroup themeable */ include __DIR__ . '/partials/siteHeader.inc'; $pageView = views_get_page_view(); $modifier_class = ''; if (isset($node) && $node->type == 'news_release') { $modifier_class = 'mod-pressRelease'; } if (isset($node) && (!empty($node->field_cover_image) || !empty($node->field_page_header_image) || !empty($pageView) || $node->type == 'news_release')) { echo '<style type="text/css">'; if (!empty($node->field_cover_image)) { $cover = mediamanager_field_url($node->field_cover_image, 'Cover'); echo "\n .cob-pageHeader { background-image:url('{$cover}'); }\n "; } if (!empty($node->field_page_header_image)) { $a1 = mediamanager_field_url($node->field_page_header_image, 'Page Header'); $a2 = mediamanager_field_url($node->field_page_header_image, 'Page Header@2'); echo "\n .cob-pageHeader-container:before { background-image:url('{$a1}'); }\n @media screen and (min-resolution: 2dppx) {\n .cob-pageHeader-container:before { background-image:url('{$a2}'); }\n }\n "; }
print t('Home'); ?> "> <img src="/<?php echo $directory; ?> /images/lsy_logo_mobile.png" alt="<?php print t('Home'); ?> " class="img-responsive" /> </a> </div> </div> <div class="page-content col-sm-9 no-padding"> <?php $this_page = views_get_page_view(); if (!$this_page) { ?> <div class="page-not-view"> <div id="not-view-wrapper" class="col-sm-6 col-sm-offset-6"> <div class="page-text-wrapper"> <h3 class="page-title"> <?php print render($title); ?> </h3> <div class="not-view-content"> <?php print render($page['content']); ?> </div>
function sunshine_preprocess_page(&$vars) { $page_classes = array(); // add front if ($vars['is_front']) { $page_classes[] = 'page-front'; } else { $page_classes[] = 'page-not-front'; } // add node type and nid to page_classes if ($vars['node']) { $page_classes[] = 'page-' . $vars['node']->type; $page_classes[] = 'page-nid-' . $vars['node']->nid; } // add view-id to page_classes $view = views_get_page_view(); if ($view) { $view_name = strtolower(preg_replace('/[^A-Za-z0-9-]/', '-', $view->view->name)); $view_id = strtolower(preg_replace('/[^A-Za-z0-9-]/', '-', $view->display->id)); $page_classes[] = 'page-view-' . $view_name; $page_classes[] = 'page-view-' . $view_name . '-' . $view_id; } $page_classes = array_filter($page_classes); $vars['page_classes'] = implode(' ', $page_classes); }