More on Drupal
Theming this week
• Theming with Skinr! (Jacine Rodriguez) —
Right after this session, right here in this
room.
• All your html are belong to us (Morten) —
Wednesday at 4:15pm.
• Sprint on Thursday — Free! Open! Friendly!
!"#$%&"'()*%+,-./01
Grok means to understand so thoroughly
that the observer becomes a part of the
observed — to merge, blend, intermarry,
lose identity in group experience.
Robert A. Heinlein, Stranger in a Strange Land
Assumptions
• You know HTML/xhtml • You don't know PHP
(but if you do, we won't
• You know CSS 2.1 hold it against you)
• You are at least getting • You understand some
basic Drupal
to know CSS 3 (or want
to) architecture concepts
• Drupal theming confuses • You want to learn this
or mystifies you
Some PHP required
• Mainly to printthe page title).
e.g., $title (for
pre-defined variables …
• You can do a lot in the "preprocess" and
"process" functions.
• You can avoidof you. totally scarescopy living
daylights out
it if it
Just stick to
the
and
paste from '<?php' to '?>'.
Drupal 7 is more
complex than Drupal 6
...but it's also more simple
Anatomy of a Drupal "page"
• xhtml, CSS, images
• Content presented via
templates
• JavaScript
The Drupal theme
• CSS files
• Image files
• Template files
• JavaScript files
• Preprocess and process files new!
• .info file
The Semantic Page
• Logo/branding/site name
• [main nav]*
• <h1> Title (of article, view, blog post, etc.)
• Main content
• Then sidebar(s), footer
* and that's debated
May I
recommend.... !"!#$%&
'&()*+#',-./0,&-
PHP for Drupal Designers,
by Emma Jane Hogbin
!"#$%%&#'&()#*+,-.(#
!""#$%!&'()*+*,!"!-.+"!"!///-%!&'()*+*,!"!-.+"!
designtotheme.com
Create a theme from scratch,
making everything
• theme .info file
• page.tpl.php
• *.tpl.php files as
needed to override
core
• template.php for your
preprocess and
postprocess
• background images
yourtheme.info
name = yourtheme
description = This is where you describe your theme in words.
version = 1.0
; Requirements
base theme = ninesixty
core = 7.x
engine = phptemplate
; Stylesheets
stylesheets[screen][] = styles/base.css
stylesheets[screen][] = styles/layout.css
stylesheets[screen][] = styles/colors.css
stylesheets[screen][] = styles/forms.css
stylesheets[print][] = styles/print.css
; Regions
regions[header] = Header
regions[help] = Help
regions[highlight] = Highlight
regions[content] = Content
regions[page_top] = Page top
regions[page_bottom] = Page bottom
regions[indicators] = Indicators
regions_hidden[] = indicators
; Scripts
scripts[] = scripts/twitter.js
yourtheme.info
name = yourtheme
description = This is where you describe your theme in words.
version = 1.0
; Requirements
base theme = ninesixty
core = 7.x
engine = phptemplate
; Stylesheets
stylesheets[screen][] = styles/base.css
stylesheets[screen][] = styles/layout.css
stylesheets[screen][] = styles/colors.css
stylesheets[screen][] = styles/forms.css
stylesheets[print][] = styles/print.css
; Regions
regions[header] = Header
regions[help] = Help
regions[highlight] = Highlight
regions[content] = Content
regions[page_top] = Page top
regions[page_bottom] = Page bottom
regions[indicators] = Indicators new!
regions_hidden[] = indicators
; Scripts
scripts[] = scripts/twitter.js
Template Suggestions
• Create a base template of that type
• Create variations on it to apply in certain
circumstances
• No coding necessary
http://drupal.org/node/190815
Template Suggestions
by content type
node.tpl.php
blog node--blog.tpl.php
event node--event.tpl.php
classified node--classified.tpl.php
product node--product.tpl.php
Template Suggestions
by content type
new!
node.tpl.php
blog node--blog.tpl.php
event node--event.tpl.php
classified node--classified.tpl.php
product node--product.tpl.php
Delimiters use two: '--'
Words still use one: '-'
event-meeting node--event-meeting.tpl.php
event-party node--event-party.tpl.php
Be nice to
robots!
photo: Don Solo
flickr.com/photos/donsolo/3950364004/
RDFa
• Robot food
• Anlearn language
to
entire
• Theming just got a
lot more technical
photo: Don Solo
flickr.com/photos/donsolo/3950364004/
Do I really need to
do RDFa to use
Drupal?
No, you can just ignore
it, and work on the same
level as other systems.
But you'll be missing
out.
Photo: FlySi
flickr.com/photos/flysi/183272970/
Basics to Remember
• Create your theme in
sites/all/themes/yourtheme
• Copy templates into your theme to make
overrides
• Use template suggestions to break out
distinct structures and stylings
• Use base theme to get a jump on things
• Let Drupal do what it does best
Get Drush!
Yeah yeah yeah, I know, you don't like command line, but this will really really and for true help you save time
developing so that you can spend more time designing and theming, and isn't that what you'd rather do anyway?
Video to make it easy:
http://is.gd/ a Ze 3 3