3. About this talk
●
There are a lot of theme snippets available in the Theme Guide. There
is not, however, a lot of information about PHP which is the language
that makes up these snippets. If you're tired of copying, pasting and
praying and are ready to understand some of the magic behind those
snippets, this session is for you!
●
In this session you will learn how to manipulate and master:
●
The very, very basics of PHP and the popular theming engine
PHPtemplate
●
Variables and tpl.php template files
●
Arrays and objects and other crowbarworthy data containers.
●
The really scary looking stuff that's in the mysterious file
template.php
●
Examples will be pulled from the Drupal.org Theme Guide as well as
the wildly successful book on theming, Front End Drupal (coauthored
by Emma Jane and Konstantin Kaefer).
21. PHPtemplate
Decide on the dance
Choose your clothes Dance the dance
http://www.kodakgallery.com/Slideshow.jsp?mode=fromshare&Uc=6m9np57.9mj7q0yf&Uy=ripni&Ux=0
22. PHPtemplate
Collect the content from
Drupal using modules Run through the Print the variables
Drupal theme in your template
functions & your files
custom theme layer
http://www.kodakgallery.com/Slideshow.jsp?mode=fromshare&Uc=6m9np57.9mj7q0yf&Uy=ripni&Ux=0
23. How to create themes
1.Download an existing theme.
2.Look for variables and functions.
3.Alter the placement of the “printed” things.
4.Save and upload the theme files.
5.Clear the theme registry (Drupal admin).
6.Enjoy your new theme.
33. tpl.php files
●
Look for basic files:
●
/modules
●
Download Zen.
●
Download Root Candy.
●
Copy tpl.php files into your theme's folder.
●
Manipulate them.
34. Conditionals
if (you're the inside couple) {
go clockwise
} else {
go counter clockwise.
}
http://www.dehnbase.org/sd/tutorial/counterrotate.php?p=4
44. “Advanced” PHP
●
Never be afraid to try something.
●
Always back up your files first.
●
Use version control.
●
Take a LOT of notes.
●
Be bold! And be brave!
45. Lessons from Drawing Class
1. Imagine what you want.
2. Make a gesture drawing.
3. Fill out the details.
50. More Homework
●
Find a snippet in the theming guide at:
http://drupal.org/node/45471
●
Figure out what it does.
●
Test it out in your theme.
●
Fix the documentation if it's wrong.
51. template.php: sup with that?
●
Preparing variables that weren't assembled by
Drupal and its modules.
●
Altering the contents of variables that were
prepared by Drupal and its modules.
●
Special theming functions to do fun things like
'edit this block' links and random images.
●
Read the Zen base theme documentation and
template.php file.
57. Even More Homework
●
Download and dissect the Zen Theme
●
http://drupal.org/project/zen
●
Read Chapter 4 of Front End Drupal
●
http://www.informit.com/articles/article.aspx?p=1336146
●
Imagine why you'd want a new template
variable.
●
Create a preprocess function.
59. In short.....PHP theming essentials:
● PHP is a linear “programming” language, just like a
dance.
● PHP stores information in variables and actions in
functions.
● Sometimes variables hold lots of information in
special variables called “arrays” and objects.
● PHP and Drupal both have functions.
● Drupal has lots of magic variables that are loaded
with content. Check out: http://drupal.org/theme
guide
63. Conditionals
if (you're the inside couple) {
go clockwise
} else {
go counter clockwise.
}
http://www.dehnbase.org/sd/tutorial/counterrotate.php?p=4
64. Snippets &
Variables
●
Create a library.
●
Use a base theme.
●
Beg, borrow, steal snippets. GPL 'em and
give 'em back to the community.