SlideShare a Scribd company logo
Functional FIPS
PHP for Drupal Designers and Themers




www.hicktech.com
@emmajanedotnet
                    
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 crow­bar­worthy 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 (co­authored 
        by Emma Jane and Konstantin Kaefer).
                                             
 
    Stick around, I've got copies to give away.
                           
Drupal Theme Guide
    http://drupal.org/theme­guide




                   
Theme snippets
    http://drupal.org/node/45471




                   
Learning through analogies
                 
 
    www.travelinghoedowners.com
                  
    bootstrapping
           
Variables



   
http://www.jontwest.com/Pro­Bono.php    
Variables




         
Contents of variables
    exist inside their containers




                   
Contents of variables
         exist inside their containers




http://www.laboutiquedupetitprince.com/en/figures­56/pixi­81/pixi­figure­the­little­
                                        
prince­sheep­box­518.html
Regions



   
http://opswingers.free.fr/cestquoi.htm    
Regions




        
Functions



                                       
    http://www.dehnbase.org/sd/tutorial/counter­rotate.php?p=4
Functions

user_is_logged_in ()

user_access ('access administration pages')

in_array ('admin', array_values ($user­>roles))




                         
 
                    Theming
http://usawestwa.com/Outfit/
                                
 
                Theming
www.squaredanceomaha.org/dress
                                  
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
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
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.


                            
page.tpl.php template file
<!DOCTYPE html PUBLIC "­//W3C//DTD XHTML 1.0 Strict//EN"
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1­strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="<?php print 
$language­>language ?>" xml:lang="<?php print $language­>language ?
>">
  <head>
    <title><?php print $head_title ?></title>
    <?php print $head ?>
    <?php print $styles ?>
  </head>
  <body>
    <div id="container">
      <div id="header">
        <div id="logoWrapper">
          <?php if ($logo) { ?>
          <div id="logo">
            <a href="<?php print $base_path ?>" title="<?php print 
t('Home') ?>"><img src="<?php print $logo ?>" alt="<?php print 
t('Home') ?>" /></a>
          </div><?php } ?>
                                   
page.tpl.php template file
<!DOCTYPE html PUBLIC "­//W3C//DTD XHTML 1.0 Strict//EN"
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1­strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="<?php print 
$language­>language ?>" xml:lang="<?php print $language­>language ?
>">
  <head>
    <title><?php print $head_title ?></title>
    <?php print $head ?>
    <?php print $styles ?>
  </head>
  <body>
    <div id="container">
      <div id="header">
        <div id="logoWrapper">
          <?php if ($logo) { ?>
          <div id="logo">
            <a href="<?php print $base_path ?>" title="<?php print 
t('Home') ?>"><img src="<?php print $logo ?>" alt="<?php print 
t('Home') ?>" /></a>
          </div><?php } ?>
                                   
Variables must be printed


    <?php print                               ?>




                                 
Variables must be printed

<title><?php print $head_title ?></title>




                      
Zomg what are those variables?
    ●
        Look at /modules/system/page.tpl.php
        OR
    ●
        http://api.drupal.org/api/drupal/modules­­
        system­­page.tpl.php/6




                             
page.tpl.php template file
<!DOCTYPE html PUBLIC "­//W3C//DTD XHTML 1.0 Strict//EN"
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1­strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="<?php print 
$language­>language ?>" xml:lang="<?php print $language­>language ?
>">
  <head>
    <title><?php print $head_title ?></title>
    <?php print $head ?>
    <?php print $styles ?>
  </head>
  <body>
    <div id="container">
      <div id="header">
        <div id="logoWrapper">
          <?php if ($logo) { ?>
          <div id="logo">
            <a href="<?php print $base_path ?>" title="<?php print 
t('Home') ?>"><img src="<?php print $logo ?>" alt="<?php print 
t('Home') ?>" /></a>
          </div><?php } ?>
                                   
Conditionals
                                                if (you're the inside couple) {
                                                     go clockwise
                                                }

                                                } else {
                                                     go counter clockwise.
                                                }




                                       
    http://www.dehnbase.org/sd/tutorial/counter­rotate.php?p=4
What's an “if”?
if ($logo) {
    <?php print                               ?>
}




                                 
Fancy data structures: arrays + objects
                     Grouping and sorting your data




                        
Fancy data structures: arrays


                                          Multiple “drawers” of sorted content




                                       
Multiple values stored in one array
Devel Module: Themer Info




                 
$node object

$node­>nid
$node­>body
$node­>content['body'][#value]




                                  
“Advanced” PHP
    ●
        Never be afraid to try something.
    ●
        Always back up your files first.
    ●
        Take a LOT of notes.
    ●
        Be bold! And be brave!




                                
template.php: what's up 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.

                               
Using template.php




Collect the content from 
 Drupal using modules             Create new                                           Print the variables 
 and run it through the       information to feed                                       in your template 
default theme functions          to your theme                                                 files
  provided by Drupal.




                                                 
                            http://www.kodakgallery.com/Slideshow.jsp?mode=fromshare&Uc=6m9np57.9mj7q0yf&Uy=ripni&Ux=0
PHP Snippet
                   from: http://drupal.org/node/21401


    <?php if ($submitted) { ?>
    <span class="submitted">
    <?php  if ($node­>type == 'blog') {
           print 'Posted ' . format_date($node­>created, 'custom', 
    "F jS, Y") . ' by ' . theme('username', $node);
           }
           else {
           print 'By ' . theme('username', $node) . ' <br /> ' . 
    format_date($node­>created, 'custom', "F jS, Y") ;
           }      
    ?>
    </span>
    <?php } ?>




                                    
Summarizing PHP for Designers
    ●
        PHP is a linear “programming” language, 
        just like a dance.
    ●
        PHP stores information in variables.
    ●
        Sometimes variables hold lots of information 
        in special variables called “arrays.”
    ●
        Drupal has lots of magic variables that are 
        loaded with content. Check out: 
        http://drupal.org/theme­guide
                              
 
                    Theming
http://usawestwa.com/Outfit/
                                
Variables



   
http://www.jontwest.com/Pro­Bono.php    
Regions



   
http://opswingers.free.fr/cestquoi.htm    
Functions



                                       
    http://www.dehnbase.org/sd/tutorial/counter­rotate.php?p=4
Conditionals
                                                if (you're the inside couple) {
                                                     go clockwise
                                                }

                                                } else {
                                                     go counter clockwise.
                                                }




                                       
    http://www.dehnbase.org/sd/tutorial/counter­rotate.php?p=4
Ready to rope 
  yourself a 
  theme?
@emmajanedotnet
www.hicktech.com <­­­ theming classes
Front End Drupal <­­­ theming book
                             

                            http://www.flickr.com/photos/fkehren/3352577815/

More Related Content

What's hot (9)

PDF
Design to Theme @ CMSExpo
Emma Jane Hogbin Westby
 
DOC
Articulo java web
I.S.T. Santo Domingo
 
PDF
Pamela - Brining back the pleasure of hand-written HTML - Montréal Python 8
spierre
 
PDF
Html5 & CSS overview
Ivan Frantar
 
KEY
Beyond HTML - Scriptsprachen, Frameworks, Templatesprachen und vieles mehr
Jens-Christian Fischer
 
PPTX
The Way to Theme Enlightenment 2017
Amanda Giles
 
PDF
Streamlining Your Applications with Web Frameworks
guestf7bc30
 
PPT
Upload[1]
lenimartina
 
PDF
Drupal 8 simple page: Mi primer proyecto en Drupal 8.
Samuel Solís Fuentes
 
Design to Theme @ CMSExpo
Emma Jane Hogbin Westby
 
Articulo java web
I.S.T. Santo Domingo
 
Pamela - Brining back the pleasure of hand-written HTML - Montréal Python 8
spierre
 
Html5 & CSS overview
Ivan Frantar
 
Beyond HTML - Scriptsprachen, Frameworks, Templatesprachen und vieles mehr
Jens-Christian Fischer
 
The Way to Theme Enlightenment 2017
Amanda Giles
 
Streamlining Your Applications with Web Frameworks
guestf7bc30
 
Upload[1]
lenimartina
 
Drupal 8 simple page: Mi primer proyecto en Drupal 8.
Samuel Solís Fuentes
 

Similar to Functional FIPS: Learning PHP for Drupal Theming (20)

PDF
Drupal Front End PHP
Emma Jane Hogbin Westby
 
PDF
Learning PHP for Drupal Theming, DC Chicago 2009
Emma Jane Hogbin Westby
 
PPTX
Theming Drupal 6 - An Introduction to the Basics
Erik Baldwin
 
PDF
Drupal Theming An Introduction
Lauren Roth
 
PPTX
Drupal Camp Porto - Developing with Drupal: First Steps
Luís Carneiro
 
PDF
Drupal 7 Theming - Behind the scenes
ramakesavan
 
ODP
DrupalEasy: Intro to Theme Development
ultimike
 
PPTX
Theming Drupal: Beyond the Look and Feel
Chris Albrecht
 
PDF
Drupal theming training
dropsolid
 
KEY
PSD to Drupal - Introductory Drupal Theming
sheenadonnelly
 
PDF
Drupal Flyover, CMS Expo
Emma Jane Hogbin Westby
 
PPTX
Drupal Theme Development
Web Development Montreal
 
PDF
Drupal theming - a practical approach (European Drupal Days 2015)
Eugenio Minardi
 
PDF
There's a Module for That, MIMA Summit 2010
Emma Jane Hogbin Westby
 
PPTX
Drupal theme development
Fortune Innovations Dublin
 
PDF
Drupal Render API
Pavel Makhrinsky
 
PPT
Drupal Bootcamp Mcn2008
Robert J. Stein
 
PDF
(some) Drupal Theming by Ryan Price
Ryan Price
 
PPT
SynapseIndia drupal presentation on drupal best practices
Synapseindiappsdevelopment
 
PDF
Building a Custom Theme in Drupal 8
Anne Tomasevich
 
Drupal Front End PHP
Emma Jane Hogbin Westby
 
Learning PHP for Drupal Theming, DC Chicago 2009
Emma Jane Hogbin Westby
 
Theming Drupal 6 - An Introduction to the Basics
Erik Baldwin
 
Drupal Theming An Introduction
Lauren Roth
 
Drupal Camp Porto - Developing with Drupal: First Steps
Luís Carneiro
 
Drupal 7 Theming - Behind the scenes
ramakesavan
 
DrupalEasy: Intro to Theme Development
ultimike
 
Theming Drupal: Beyond the Look and Feel
Chris Albrecht
 
Drupal theming training
dropsolid
 
PSD to Drupal - Introductory Drupal Theming
sheenadonnelly
 
Drupal Flyover, CMS Expo
Emma Jane Hogbin Westby
 
Drupal Theme Development
Web Development Montreal
 
Drupal theming - a practical approach (European Drupal Days 2015)
Eugenio Minardi
 
There's a Module for That, MIMA Summit 2010
Emma Jane Hogbin Westby
 
Drupal theme development
Fortune Innovations Dublin
 
Drupal Render API
Pavel Makhrinsky
 
Drupal Bootcamp Mcn2008
Robert J. Stein
 
(some) Drupal Theming by Ryan Price
Ryan Price
 
SynapseIndia drupal presentation on drupal best practices
Synapseindiappsdevelopment
 
Building a Custom Theme in Drupal 8
Anne Tomasevich
 
Ad

More from Emma Jane Hogbin Westby (20)

PDF
Managing a Project the Drupal Way - Drupal Open Days Ireland
Emma Jane Hogbin Westby
 
PDF
Was it something I said?
Emma Jane Hogbin Westby
 
PDF
HOWTO Empathy
Emma Jane Hogbin Westby
 
PDF
Getting a CLUE at the Command Line
Emma Jane Hogbin Westby
 
PDF
Lessons From an Unlikely Superhero
Emma Jane Hogbin Westby
 
PDF
PSD to Theme: The SMACSS Way
Emma Jane Hogbin Westby
 
PDF
Git Makes Me Angry Inside - DrupalCon Prague
Emma Jane Hogbin Westby
 
PDF
Git Makes Me Angry Inside
Emma Jane Hogbin Westby
 
PDF
Was It Something I Said? The Art of Giving (and getting) A Critique
Emma Jane Hogbin Westby
 
PDF
Beyond the Bikeshed
Emma Jane Hogbin Westby
 
PDF
Gamestorming Meets Quiet
Emma Jane Hogbin Westby
 
PDF
Git Makes Me Angry Inside
Emma Jane Hogbin Westby
 
PDF
Work Flow for Solo Developers and Small Teams
Emma Jane Hogbin Westby
 
PDF
Evaluating Base Themes
Emma Jane Hogbin Westby
 
PDF
Speaker Check-in - 3 - Munich
Emma Jane Hogbin Westby
 
PDF
Responsive Web Design for Drupal, CMS Expo
Emma Jane Hogbin Westby
 
PDF
Selling Hopes and Dreams - DrupalCamp Toronto
Emma Jane Hogbin Westby
 
PDF
Forensic Theming - DrupalCon London
Emma Jane Hogbin Westby
 
PDF
Forensic Theming for Drupal
Emma Jane Hogbin Westby
 
PDF
Advanced Layout Techniques @ CMSExpo
Emma Jane Hogbin Westby
 
Managing a Project the Drupal Way - Drupal Open Days Ireland
Emma Jane Hogbin Westby
 
Was it something I said?
Emma Jane Hogbin Westby
 
Getting a CLUE at the Command Line
Emma Jane Hogbin Westby
 
Lessons From an Unlikely Superhero
Emma Jane Hogbin Westby
 
PSD to Theme: The SMACSS Way
Emma Jane Hogbin Westby
 
Git Makes Me Angry Inside - DrupalCon Prague
Emma Jane Hogbin Westby
 
Git Makes Me Angry Inside
Emma Jane Hogbin Westby
 
Was It Something I Said? The Art of Giving (and getting) A Critique
Emma Jane Hogbin Westby
 
Beyond the Bikeshed
Emma Jane Hogbin Westby
 
Gamestorming Meets Quiet
Emma Jane Hogbin Westby
 
Git Makes Me Angry Inside
Emma Jane Hogbin Westby
 
Work Flow for Solo Developers and Small Teams
Emma Jane Hogbin Westby
 
Evaluating Base Themes
Emma Jane Hogbin Westby
 
Speaker Check-in - 3 - Munich
Emma Jane Hogbin Westby
 
Responsive Web Design for Drupal, CMS Expo
Emma Jane Hogbin Westby
 
Selling Hopes and Dreams - DrupalCamp Toronto
Emma Jane Hogbin Westby
 
Forensic Theming - DrupalCon London
Emma Jane Hogbin Westby
 
Forensic Theming for Drupal
Emma Jane Hogbin Westby
 
Advanced Layout Techniques @ CMSExpo
Emma Jane Hogbin Westby
 
Ad

Recently uploaded (20)

PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 

Functional FIPS: Learning PHP for Drupal Theming