Open Framework Theme: Incorporating Twitter Bootstrap into Drupal

Brian Young
May 5, 2012

What is Twitter Bootstrap?

twitter.github.com/bootstrap/

What is Open Framework?

su-sws.github.com/open_framework

Why should I use Open Framework?

Open Framework: Block Regions

12-column grid

Page: Top Section (12-column)
Page: Upper Section (12-column)
Page: Feature Section (12-column)
Site: First sidebar (3-column) Content: Top section (6-column) Site: Second sidebar (3-column)
Content: Upper Section (6-column)
Content: Body (6-column)
Content: Lower Section (6-column)
Content: Bottom Section (6-column)
Page: Lower Section (12-column)
Page: Bottom Section (12-column)

Open Framework: Block Widths

Page: Feature Section (12-column)
Block #1
4-column
Block #2
4-column
Block #3
4-column
Site: First sidebar (3-column) Content: Upper section (6-column)
Block #1
2-column
Block #2
2-column
Block #3
2-column
Site: Second sidebar (3-column)
Content: Lower Section (6-column)
Block #1
3-column
Block #2
3-column

Open Framework: Block Widths (Cont.)

Page: Feature Section (12-column)
Block #1
4-column
Block #2
4-column
Block #3
4-column
Content: Upper section (9-column)
Block #1
3-column
Block #2
3-column
Block #3
3-column
Site: Second sidebar (3-column)
Content: Lower Section (9-column)
Block #1
3-column
Block #2
6-column

Quirks and Bugs

Bootstrap javascript components are not loaded by default

Enabling jQuery 1.7.1 and bootstrap.js

<?php
drupal_add_js('sites/all/themes/open_framework/js/jquery-1.7.1.min.js',
 'theme', 'header', FALSE, FALSE, FALSE);
drupal_add_js('sites/all/themes/open_framework/js/bootstrap.min.js', 
 'theme', 'header', FALSE, FALSE, FALSE);
?>

Open Framework in Action

itopenhouse.stanford.edu

Hide Address Bar Automatically on Page Load

addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false);
	function hideURLbar(){
		if (window.pageYOffset < 1) {
	window.scrollTo(0, 1);
	}
}

Positions search box dynamically

Desktop View

Mobile View

IT Open House Site Case Study

CSS Injector Changes

@import url(http://fonts.googleapis.com/css?family=Cabin:700,400,400italic);
h1, h2, h3, h4, h5, p, a, li, th, td {font-family: 'Cabin', sans-serif;}
body {
    background: #cad9e7 url('images/body_background_fullcolor.jpg');
    background-attachment: fixed; 
    background-size: cover;
    }
#main-content {
    background-color: rgba(255,255,255,0.9);
    border-radius: 10px;
    }

IT Open House Site Case Study

Mobile Optimized Content Layout

@media (max-width: 480px) {
	body {background: #b8d3f8;}
	table th {display: none;}
	table td {display: block; width: auto;}
	table td:nth-child(2), table td:nth-child(3) {border: none;}
	}

Open Framework Sub-theming at Stanford

Stanford Wilbur Theme (sites.stanford.edu/demo)

Related Drupal.org projects

Thank you!