Hi,
is it possible to override original templates when i use sub-theme?
I need to change grid values for base layout, hide breadcrumbs etc. and i don't want to edit original templates...

Thanks for reply

Comments

illy’s picture

Version: 7.x-1.x-dev » 7.x-1.6
VFXCode’s picture

Yes you can.

make a template.php file in the root of your subtheme and just add the functions you want to override changing the function name to reflect your subtheme.

For example a subtheme called "skysubtheme" should have the following written in the template.php file to become a 12 collum grid

<?php

/**
 * Implements template_preprocess_page().
 */
function skysubtheme_preprocess_page(&$vars) {
  // Shorten the sidebar variable names.
  $sidebar_1 = $vars['page']['sidebar_first'];
  $sidebar_2 = $vars['page']['sidebar_second'];
  // Grid size for sidebars for 2-column layout.
  $width = 4;
  // Grid size for sidebars for 3-column layout.
  if (!empty($sidebar_1) && !empty($sidebar_2)) {
    $width = 3;
  }
  // Define grid classes for page.tpl.php
  $vars['content_grid_classes'] = sky_ns('grid-12', $sidebar_1, $width, $sidebar_2, $width) . ' ' . sky_ns('push-' . $width, !$sidebar_1,  $width);
  $vars['sidebar_first_grid_classes'] = 'grid-' . $width . ' ' . sky_ns('pull-' . (12 - $width), $sidebar_2, $width);
  $vars['sidebar_second_grid_classes'] = 'grid-' . $width;

  // Add text for unpublished nodes.
  if (isset($vars['node']) && $vars['node']->status == 0) {
    $vars['title'] =  drupal_get_title() . ' <span class="marker">(' . t('Unpublished') . ')</span>';
  }
}