Example #1
0
/**
 * Intercept page template variables
 *
 * @param $vars
 *   A sequential array of variables passed to the theme function.
 */
function phptemplate_preprocess_page(&$vars)
{
    global $user;
    $vars['path'] = base_path() . path_to_theme() . '/';
    $vars['user'] = $user;
    // Fixup the $head_title and $title vars to display better.
    $title = drupal_get_title();
    $headers = drupal_set_header();
    // wrap taxonomy listing pages in quotes and prefix with topic
    if (arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2))) {
        $title = t('Topic') . ' “' . $title . '”';
    } else {
        if (strpos($headers, 'HTTP/1.1 403 Forbidden') && !$user->uid) {
            $title = t('Please login to continue');
        }
    }
    $vars['title'] = $title;
    if (!drupal_is_front_page()) {
        $vars['head_title'] = $title . ' | ' . $vars['site_name'];
        if ($vars['site_slogan'] != '') {
            $vars['head_title'] .= ' – ' . $vars['site_slogan'];
        }
    }
    // determine layout
    // 3 columns
    if ($vars['layout'] == 'both') {
        $vars['left_classes'] = 'col-left span-6';
        $vars['right_classes'] = 'col-right span-6 last';
        $vars['center_classes'] = 'col-center span-12';
        $vars['body_classes'] .= ' col-3 ';
    } else {
        if ($vars['layout'] != 'none') {
            // left column & center
            if ($vars['layout'] == 'left') {
                $vars['left_classes'] = 'col-left span-6';
                $vars['center_classes'] = 'col-center span-18 last';
            } else {
                if ($vars['layout'] == 'right') {
                    $vars['right_classes'] = 'col-right span-6 last';
                    $vars['center_classes'] = 'col-center span-18';
                }
            }
            $vars['body_classes'] .= ' col-2 ';
        } else {
            $vars['center_classes'] = 'col-center span-24';
            $vars['body_classes'] .= ' col-1 ';
        }
    }
    $vars['meta'] = '';
    // SEO optimization, add in the node's teaser, or if on the homepage, the mission statement
    // as a description of the page that appears in search engines
    if ($vars['is_front'] && $vars['mission'] != '') {
        $vars['meta'] .= '<meta name="description" content="' . blueprint_trim_text($vars['mission']) . '" />' . "\n";
    } else {
        if (isset($vars['node']->teaser) && $vars['node']->teaser != '') {
            $vars['meta'] .= '<meta name="description" content="' . blueprint_trim_text($vars['node']->teaser) . '" />' . "\n";
        } else {
            if (isset($vars['node']->body) && $vars['node']->body != '') {
                $vars['meta'] .= '<meta name="description" content="' . blueprint_trim_text($vars['node']->body) . '" />' . "\n";
            }
        }
    }
    // SEO optimization, if the node has tags, use these as keywords for the page
    if (isset($vars['node']->taxonomy)) {
        $keywords = array();
        foreach ($vars['node']->taxonomy as $term) {
            $keywords[] = $term->name;
        }
        $vars['meta'] .= '<meta name="keywords" content="' . implode(',', $keywords) . '" />' . "\n";
    }
    // SEO optimization, avoid duplicate titles in search indexes for pager pages
    if (isset($_GET['page']) || isset($_GET['sort'])) {
        $vars['meta'] .= '<meta name="robots" content="noindex,follow" />' . "\n";
    }
    /* I like to embed the Google search in various places, uncomment to make use of this
      // setup search for custom placement
      $search = module_invoke('google_cse', 'block', 'view', '0');
      $vars['search'] = $search['content'];
      */
    /* to remove specific CSS files from modules use this trick
      // Remove stylesheets
      $css = $vars['css'];
      unset($css['all']['module']['sites/all/modules/contrib/plus1/plus1.css']);
      $vars['styles'] = drupal_get_css($css);   
      */
}
Example #2
0
/**
 * Intercept page template variables
 *
 * @param $vars
 *   A sequential array of variables passed to the theme function.
 */
function blueprint_preprocess_page(&$vars)
{
    global $user;
    $vars['path'] = base_path() . path_to_theme() . '/';
    $vars['path_parent'] = base_path() . drupal_get_path('theme', 'blueprint') . '/';
    $vars['user'] = $user;
    // Prep the logo for being displayed
    $site_slogan = !$vars['site_slogan'] ? '' : ' - ' . $vars['site_slogan'];
    $logo_img = '';
    $title = $text = variable_get('site_name', '');
    if ($vars['logo']) {
        $logo_img = "<img src='" . $vars['logo'] . "' alt='" . $title . "' border='0' />";
        $text = $vars['site_name'] ? $logo_img . $text : $logo_img;
    }
    $vars['logo_block'] = !$vars['site_name'] && !$vars['logo'] ? '' : l($text, '', array('attributes' => array('title' => $title . $site_slogan), 'html' => !empty($logo_img)));
    // Even though the site_name is turned off, let's enable it again so it can be used later.
    $vars['site_name'] = variable_get('site_name', '');
    //Play nicely with the page_title module if it is there.
    if (!module_exists('page_title')) {
        // Fixup the $head_title and $title vars to display better.
        $title = drupal_get_title();
        $headers = drupal_set_header();
        // if this is a 403 and they aren't logged in, tell them they need to log in
        if (strpos($headers, 'HTTP/1.1 403 Forbidden') && !$user->uid) {
            $title = t('Please login to continue');
        }
        $vars['title'] = $title;
        if (!drupal_is_front_page()) {
            $vars['head_title'] = $title . ' | ' . $vars['site_name'];
            if ($vars['site_slogan'] != '') {
                $vars['head_title'] .= ' &ndash; ' . $vars['site_slogan'];
            }
        }
        $vars['head_title'] = strip_tags($vars['head_title']);
    }
    // determine layout
    // 3 columns
    if ($vars['layout'] == 'both') {
        $vars['left_classes'] = 'col-left span-6';
        $vars['right_classes'] = 'col-right span-6 last';
        $vars['center_classes'] = 'col-center span-12';
        $vars['body_classes'] .= ' col-3 ';
    } elseif ($vars['layout'] != 'none') {
        // left column & center
        if ($vars['layout'] == 'left') {
            $vars['left_classes'] = 'col-left span-6';
            $vars['center_classes'] = 'col-center span-18 last';
        } elseif ($vars['layout'] == 'right') {
            $vars['right_classes'] = 'col-right span-6 last';
            $vars['center_classes'] = 'col-center span-18';
        }
        $vars['body_classes'] .= ' col-2 ';
    } else {
        $vars['center_classes'] = 'col-center span-24';
        $vars['body_classes'] .= ' col-1 ';
    }
    $vars['meta'] = '';
    // SEO optimization, add in the node's teaser, or if on the homepage, the mission statement
    // as a description of the page that appears in search engines
    if ($vars['is_front'] && $vars['mission'] != '') {
        $vars['meta'] .= '<meta name="description" content="' . blueprint_trim_text($vars['mission']) . '" />' . "\n";
    } elseif (isset($vars['node']->teaser) && $vars['node']->teaser != '') {
        $vars['meta'] .= '<meta name="description" content="' . blueprint_trim_text($vars['node']->teaser) . '" />' . "\n";
    } elseif (isset($vars['node']->body) && $vars['node']->body != '') {
        $vars['meta'] .= '<meta name="description" content="' . blueprint_trim_text($vars['node']->body) . '" />' . "\n";
    }
    // SEO optimization, if the node has tags, use these as keywords for the page
    if (isset($vars['node']->taxonomy)) {
        $keywords = array();
        foreach ($vars['node']->taxonomy as $term) {
            $keywords[] = $term->name;
        }
        $vars['meta'] .= '<meta name="keywords" content="' . implode(',', $keywords) . '" />' . "\n";
    }
    // SEO optimization, avoid duplicate titles in search indexes for pager pages
    if (isset($_GET['page']) || isset($_GET['sort'])) {
        $vars['meta'] .= '<meta name="robots" content="noindex,follow" />' . "\n";
    }
    if (theme_get_setting('blueprint_showgrid')) {
        $vars['body_classes'] .= ' showgrid ';
    }
    //Setup the vars for the Blueprint Libraries location.
    if (module_exists('libraries')) {
        $vars['bp_library_path'] = module_invoke('libraries', 'get_path', 'blueprint') . '/';
    } else {
        $vars['bp_library_path'] = 'sites/all/libraries/blueprint/';
    }
    //Add the screen and print css files
    drupal_add_css($vars['bp_library_path'] . 'blueprint/screen.css', 'theme', 'screen,projection');
    $vars['css'] = drupal_add_css($vars['bp_library_path'] . 'blueprint/print.css', 'theme', 'print');
    //Perform RTL - LTR swap and load RTL Styles.
    if ($vars['language']->dir == 'rtl') {
        // Remove Blueprint Grid and use RTL grid
        $css = $vars['css'];
        $css['screen,projection']['theme'][$vars['bp_library_path'] . '/blueprint/plugins/rtl/screen.css'] = TRUE;
        //setup rtl css for IE
        $vars['styles_ie']['ie'] = '<link href="' . $path . 'css/ie-rtl.css" rel="stylesheet"  type="text/css"  media="screen, projection" />';
        $vars['styles_ie']['ie6'] = '<link href="' . $path . 'css/ie6-rtl.css" rel="stylesheet"  type="text/css"  media="screen, projection" />';
    }
    // Make sure framework styles are placed above all others.
    $vars['css_alt'] = blueprint_css_reorder($vars['css']);
    $vars['styles'] = drupal_get_css($vars['css_alt']);
    /* I like to embed the Google search in various places, uncomment to make use of this
      // setup search for custom placement
      $search = module_invoke('google_cse', 'block', 'view', '0');
      $vars['search'] = $search['content'];
      */
    /* to remove specific CSS files from modules use this trick
      // Remove stylesheets
      $css = $vars['css'];
      unset($css['all']['module']['sites/all/modules/contrib/plus1/plus1.css']);
      $vars['styles'] = drupal_get_css($css);
      */
}