These are slides from my presentation at Drupal Design Camp Los Angeles, February 2011. Video with rather low resolution version of the slides (we inadvertently recorded my presentation notes screen rather than the projector screen) can be viewed on blip:
http://ladrupal.blip.tv/file/4731722/
3. Grok Drupal Theming
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
5. <h1 id="title"> Grok Drupal Theming </h1>
How Drupal displays content (templates)
How to start theming
Other things to consider
6. 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
to know CSS 3 (or want basic Drupal
to) architecture concepts
ā¢ Drupal theming confuses ā¢ You want to learn this
or mystiļ¬es you
7. Some PHP required
ā¢ Mainly to print pre-deļ¬ned variables ā¦
e.g., $title (for the page title).
ā¢ You can do a lot in the "preprocess" and
"process" functions.
ā¢ You can avoid it if it totally scares the living
daylights out of you. Just stick to copy and
paste from '<?php' to '?>'.
28. Which template? html.tpl.php
page.tpl.php
node.tpl.php block.tpl.php
ā¢ Block title
ā¢ Block content
comment-wrapper.tpl.php
comment.tpl.php
*We'll come back to
this, because there's
one more very
important thing.
47. The Semantic Page
ā¢ Logo/branding/site name
ā¢ [main nav]*
ā¢ <h1> Title (of article, view, blog post, etc.)
ā¢ Main content
ā¢ Then secondary content (aka "sidebars"),
footer
* and that's debated
83. Create a theme from scratch,
making everything
ā¢ theme .info ļ¬le
ā¢ page.tpl.php
ā¢ *.tpl.php ļ¬les as
needed to override
core
ā¢ template.php for your
preprocess and
process
ā¢ background images
95. 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[all][] = styles.css
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[] = script.js
scripts[] = scripts/twitter.js
96. 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[all][] = styles.css
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[] = script.js
scripts[] = scripts/twitter.js
97. In Drupal 7,
if you're creating a theme from
scratch, you must now declare
style.css and script.js in your .info
ļ¬le, or they will not be included.
98. 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[all][] = styles.css
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[] = script.js
scripts[] = scripts/twitter.js
99. 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
100. Template Suggestions
by content type
node.tpl.php
blog node--blog.tpl.php
event node--event.tpl.php
classiļ¬ed node--classiļ¬ed.tpl.php
product node--product.tpl.php
101. Template Suggestions
by content type
new!
node.tpl.php
blog node--blog.tpl.php
event node--event.tpl.php
classiļ¬ed node--classiļ¬ed.tpl.php
product node--product.tpl.php
102. Delimiters use two: '--'
Words still use one: '-'
event-meeting node--event-meeting.tpl.php
event-party node--event-party.tpl.php
103. new!
And no longer need
node.tpl.php
in your theme
in order to use
node--event.tpl.php.
104. new!
Wildcards in tpl names
page--user--42.tpl.php
page--user--%.tpl.php
override all user displays
without affecting /user
113. Be nice to
robots!
photo: Don Solo
ļ¬ickr.com/photos/donsolo/3950364004/
114. RDFa
ā¢ Robot food
ā¢ An entire language
to learn
ā¢ Theming just got a
lot more technical
photo: Don Solo
ļ¬ickr.com/photos/donsolo/3950364004/
116. Robots just want to
Hand over I'm hungry!
your RDF! understand your site.
Hmmmmmā¦.
dataā¦..
Image: bbaltimore
ļ¬ickr.com/photos/bbaltimore/6778028/
117. Dance with
them!
It's easy!
Image: Eric__I_E
ļ¬ickr.com/photos/deadling/256390679/
124. 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
ļ¬ickr.com/photos/ļ¬ysi/183272970/
126. 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
127. Points of Modiļ¬cation
ā¢ CSS
ā¢ xhtml in the template that applies
ā¢ preprocess
ā¢ module
130. 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/ aZe33