Drupal Notes 2: sub-theme derivative of bluemarine : Theme inheritance, overriding, preprocessing

add folder to:
sites/all/themes(createThis)/subThemeName(createThis)/

create subThemeName.info (in newly created folder):
; $Id$
name = subThemeName
description = blah blah blah blah blah
version = 1.0
core = 6.x
base theme = bluemarine
stylesheets[all][] = descartes-style.css // copy images from parent theme into sub-theme.
stylesheets[all][] = new.css

finally, create above mentioned new.css (in newly created folder) and add styles you’d like to modify, example:
/*
** Style to override the styles.css in
** bluemarine.css
*/

/*
* Plain white right nav.
*/

#sidebar-right{
border-left: 1px solid #ea940c;
background-color: white;
}

ready to go further? copy any of the following over from bluemarine into yourNewSubTheme and edit away:
page.tpl.php (hint: start here), block.tpl.php, box.tpl.php, comment.tpl.php

even further, you’ve moved $breadcrumb in page.tpl.php to where you’d like it, but you want to edit INSIDE that…
these PHPTemplate functions that render content can be found in yourSite/includes/theme.inc
find the one that spits out the content you’d like to modify, and then create a template.php in your new theme directory and override that function…
example: theme_breadcrumb() uses “>>” as separators, in
yourSite/sites/all/themes/yourNewTheme/template.php (make it)
overwrite theme_breadcrumb() via something like this:


// $Id$
/**
* @page
* Override theme_() functions for the youNewTheme.
*/

// Overrides theme_breadcrumb()
function phptemplate_breadcrumb($breadcrumb){
if (empty($breadcrumb)) return;
$sep = ‘<div>&nbsp;&nbsp;</div>’;
$breadcrumb_string = ‘<div>’ . implode($sep, $breadcrumb) . ‘</div>’;
return $breadcrumb_string;
} // end of template.php example

other PHPTemplate theme functions from includes/theme.inc to investigate:
theme_image(), theme_links(), theme_progress_bar(), theme_username(), theme_table(), theme_item_list()

called as follows:
$variable = theme(‘functionName’, $arg1, $arg2, …) , which looks like this:
$crumb = theme(‘item_list’, $breadcrumb, null, ‘ul’, array(‘class’=>’breadcrumb-items’));

IMPORTANT NOTES/REMEMBER:
– a phptemplate_block() function redefined in template.php will override a block.tpl.php file in template folder!
– if you want to preprocess CONTENT before it’s passed to template.php, thus, instead use phptemplate_preprocess_functions()!
– if you’re NOT making a sub-theme, add to .info this line: engine=phptemplate instead of using the base theme line
– don’t forget to make a nice screenshot.png (150×90)

Comments are closed.