SlideShare a Scribd company logo
1 of 60
A look at how Drupal themes are created




                                          Learning Drupal Sydney
In a CMS a presentation layer displays the
     content to website visitors based on
              a set of templates

“A theme is a collection of files that define the
      presentation layer.” – Drupal.org

Think of it as the index.html with static content
            replaced by PHP variables
No, you can use modules to change the layout of a
page or section of a page.

An example of some modules are;
 Panels http://drupal.org/project/panels
 Display Suite http://drupal.org/project/ds
 Skinr http://drupal.org/project/skinr
 Block Class http://drupal.org/project/block_class

 But they only change the layout of pages not the frame
 of the site
PHP variables
are turned into
  the needed
  HTML calls
You can change your sites theme from the
“Appearance” menu option in Drupal 7

a themes can consist of a couple of .tpl files
(page.tpl.php, node.tpl.php) and on .css file

a themes can consist of many .tpl files and
multipule .css and .js files
/sites/all/themes [correct]
/themes [not correct]

Never over write core themes files that live in
the base folder of Drupal, this is called hacking
core

Don’t take a copy of a core theme to create
another theme use a contributed theme
All Drupal themes must have an info.php file,
one css file
  .info (required) > think of this as the template configuration file

All other files depend on how much you want to
customise the look of Drupal
A typical theme consists of page.tpl.php, node.tpl.php,
block.tpl.php, comment.tpl.php, style.css

http://drupal.org/node/190815 lists all core templates
Think of it as the themes configuration file
Must be named the same as the theme folder
Required in a theme
Tells Drupal about the theme
Declares themes name name = Ourtheme
Declares what version of Drupal core = 6.x
Declares css files stylesheets[all][] = style.css
Declares javascript files scripts[] = scripts/superfish.js
Declares regions regions[content] = Main content
Declares features features[] = logo
Think of it as the content between <head>
</head>
Prints out all needed CSS and JavaScript files
Does not need to be included in a file as it will
inherit the Drupal core html.tpl.php file
Allows for more granular control
Think of it as the content between <body>
</body>
You print your regions in your page.tpl.php
<?php print render ($page['preface']); ?>
Its the frame of your website
Create’s the page layout, were content is
printed, menu, search, sidebars…
Themes all nodes in the site
Prints out the output of $content variable in page.tpl.php
Controls what all node pages look like, can be overwritten by
specific templates targeting the node id or content type.
Think of nodes as the content on the page
  <div id=“content”>
       <h1>…</h1>
        <p>…</p>
  </div>

  Can theme all nodes
     node.tpl.php
  Can theme a specific node
  node--nodeid.tpl.php
Themes all blocks or themes a specific block
Allows you to wrap more HTML and CSS code
around the block or remove some HTML

Can theme all blocks
    block.tpl.php
Can theme all blocks in a specific region
    block--region.tpl.php
Can themes blocks produced by modules
    block--module.tpl.php
Themes all regions or themes a specific region
Allows you to wrap more HTML and CSS code
around the region area
Allows you to style the menu region and then the
sidebar region to have more control of Drupal
out-put
Can theme all regions
     region.tpl.php
Can theme a specific region
     region—search.tpl.php
Used to theme individual fields
Will theme all the fields that are of that type
Must flush cache when adding and removing templates
For example you create an image field and use that
across three content types, the field theme will apply
the field.tpl.php to all three content types

field.tpl.php
field--field-type.tpl.php
field--field-name.tpl.php
field--content-type.tpl.php
field--field-name--content-type.tpl.php
Themes the way that comments look
Can theme individual comments and the
comment area wrapper

Can theme the comment wrapper
    comment-wrapper.tpl.php
Can theme individual comments
    comment.tpl.php
Themes how your “Site offline” page looks

Enables you to control how your maintenance
page looks enables a more professional look

When you turn your site offline into
maintenance mode if you don’t have a specific
maintenance theme the default Drupal
maintenance template will display
   You can only use page.tpl.php variables on
    page.tpl.php as you can only use node
    variables on node.tpl.php
   This means not all variables can be printed on
    all templates, variables are template specific
   Theme inheritance applies, more about
    that…
1.   Drupal core applies its own .tpl.php files
     they are called first
2.   Drupal modules apply their own .tpl.php
     files these are applied second and over write
     any css calls that exist in core tpl.php files
3.   Your theme has its own .tpl.php files these
     are applied last and over write calls in core
     tpl.php files and module tpl.php files
4.   Your theme has the final say!
theme tpl.php files                  Theme Wins
/sites/all/themes/ourtheme/templates/node.tpl.php
                                                     module
                                                     node.tpl.php gets
                                                     overridden by the
               module tpl.php files                  them
                                                     node.tpl.php
 /sites/all/modules/examplemodule/node.tpl.php

                                                     Core
                core tpl.php files                   node.tpl.php gets
                                                     overridden by the
          /modules/node/node.tpl.php                 modules
                                                     node.tpl.php
File does not exist
                                         Core Wins
                                         There is no file to
                                         overwrite the
/sites/all/themes/ourtheme/templates/?
                                         core so it is used
                                         to create the
                                         output
          File does not exist
                                         There is no file to
 /sites/all/modules/examplemodule/?      overwrite the
                                         core tpl file


           core tpl.php files
                                         Core html.tpl.php
                                         is applied to the
     /modules/node/html.tpl.php
                                         layout
Templates within your own Theme can also be
overwritten by other templates in your theme this
allows you to be specific with your template target
Drupal.org describes it as “Template suggestions
are made based on these factors

   Listed from the most specific template to the least.

   Drupal will use the most specific template       it
    finds.”
Specific Wins
node--nodeid.tpl.php   node—nodeid.tpl.php
                       will apply to the
                       specific node that
                       matches the id number

                       node--type.tpl.php
 node--type.tpl.php    will apply to all
                       nodes of a specific
                       content type

                       node.tpl.php will
   node.tpl.php        be called to
                       theme all Drupal
                       nodes
1.   Drupal core applies its own .css file this is
     called first
2.   Drupal modules apply their own .css files
     these are applied second and over write any
     css calls that exist in core css files
3.   Your theme has its own .css files these are
     applied last and over write calls in core css
     files and module css files
4.   Your theme has the final say!
If a theme .css file has the same class call, then it will
          be overwritten by the theme css
                                                             Theme Wins
                 h1 { font-size: 3em; }                       module css calls
                                                              gets overridden
                                                              by the theme css
 If a module .css file has the same class call, then it       calls
       will be overwritten by the module css

                 h1 { font-size: 2em; }
                                                              Core css calls
           Core css files style a header tag                  get overridden by
                                                              the modules if
                h1 { font-size: 1.6em; }                      there is a file with
                                                              the same name
                                                              style.css
You see a CSS class coming from module/node/node.css?
  Don’t change the module/node/node.css file
  Do copy the css call and paste it into your
     theme.css file

You want to use your own css to style a module?
  Don’t change sites/all/modules/name/module.css
     file
  Do take a copy of the css file, place a copy of the
     module.css file into your theme folder and enter
     stylesheets[all][] = modulestyle.css into your themes
     info file Do flush cache
There are 42 different .tpl files in Drupal7 core modules
folder.
      /modules/modulename/*.tpl.php

Each one of these can be copied and placed in your own
theme to overwrite the output
     /sites/all/theme/yourtheme/templates/*.tpl.php

If a contributed module has a .tpl file this can be copied
into your theme folder and it will overwrite the .tpl in the
modules folder
       /sites/all/modules/example/*.tpl.php
1.   Take a copy of the .tpl.php file we need from
     the module
2.   Move the copy to our themes templates folder,
     this can be under the folder
       theme/templates/*.tpl.php
       or under the root of the theme folder
       theme/*.tpl.php
1.   Flush cache or flush the theme registry to see
     if we can notice the changes on the website
Theme the layout of a specific content type;

If you want to theme the news content type,
you would create;

   node-news.tpl.php
   node-content-type-machine-name.tpl.php
   Take a copy of node.tpl.php
   Rename it to node—contenttype.tpl.php
   Add the styling you want

   If you want to change the layout then you can
    use devel to locate the field names and print
    them out separately
   To do this you need to delete the $content variable
    print render replace it with calls to the specific fields
    print render($content['field_gallery_image']);
<div class="content">
 <?php
    // First we hide the comments and links now so that we can render
them later.
       hide($content['comments']);
       hide($content['links']);
  // Then we print the content. Comments and links not included here.
       print render($content);
 ?>
</div>
  // Then we print the links and comments separately

<?php print render($content['links']); ?>
<?php print render($content['comments']); ?>.
   You can use the Devel module to tell you all the
    fields you have available on a content type
   Devel render will display the name you need to
    call to print that field in the tpl file
Field variables will print out the array so if there is
1 it will print 1 or if there is 3 it will print out 3, one
after the other, an example three images files
uploaded to a node will print out three times by
calling the field
<div class="imageElement">
  <?php
     print render($content['field_gallery_image']);
     print render($content['field_galleryimagecaption']);
  ?>
</div>


print render($content['field_namehere']);
   It is a good first start
   Look for a theme that has the desired layout
   Download a theme from the Drupal.org
    website, and apply it to your website
   You need to enable the theme and set it as
    the default
If your going to change a contributed theme;

1.   Take a copy of the theme folder and give it a
     new name
2.   Rename the x.info file to match the name of
     the folder
3.   Open up the theme and change some of the
     CSS styles
4.   Change any calls to image files in the theme
     and replace them with your own
 A base theme gives you a good starting point for
  creating your own theme
 Its best to use a base theme otherwise you may
  miss needed Drupal PHP variables
 It helps reduce development time
 Takes care of a lot of the starting work in
  creating your own theme from scratch
 You can use a responsive design aka Adaptive
  base theme is a responsive design which means
  you don’t need to write the media query calls
   Sub themes inherit templates, css, js and
    functions from there base theme
   This means;
     If the base theme is based on the 960 grid system
      the sub theme will as well
     If the base theme is an adaptive theme, the sub
      theme will be as well
   It saves us time of building these features into
    our themes
   Sub themes must always have the core theme
    enabled in the Drupal appearance area
   The subtheme must be enabled and set as
    default
   Each base theme has its own documentation,
    but, generally we take a copy of one of the start
    sub-themes and we rename it to our new theme
    name
The best way to get your personalised site

But you need to understand and know the
  Drupal theme variables and structure

   So often best to use a Base Theme
Learning Drupal Sydney
Aimee Maree Forsstrom – Drupal Solution Architect

More Related Content

What's hot

Drupal 8 introduction to theming
Drupal 8  introduction to themingDrupal 8  introduction to theming
Drupal 8 introduction to themingBrahampal Singh
 
Converting (X)HTML/CSS template to Drupal 7 Theme
Converting (X)HTML/CSS template to Drupal 7 ThemeConverting (X)HTML/CSS template to Drupal 7 Theme
Converting (X)HTML/CSS template to Drupal 7 ThemeAdolfo Nasol
 
8 things to know about theming in drupal 8
8 things to know about theming in drupal 88 things to know about theming in drupal 8
8 things to know about theming in drupal 8Logan Farr
 
Drupal 8 theming deep dive
Drupal 8 theming deep diveDrupal 8 theming deep dive
Drupal 8 theming deep diveRomain Jarraud
 
Building a Custom Theme in Drupal 8
Building a Custom Theme in Drupal 8Building a Custom Theme in Drupal 8
Building a Custom Theme in Drupal 8Anne Tomasevich
 
Learning PHP for Drupal Theming, DC Chicago 2009
Learning PHP for Drupal Theming, DC Chicago 2009Learning PHP for Drupal Theming, DC Chicago 2009
Learning PHP for Drupal Theming, DC Chicago 2009Emma Jane Hogbin Westby
 
Intro to Theming Drupal, FOSSLC Summer Camp 2010
Intro to Theming Drupal, FOSSLC Summer Camp 2010Intro to Theming Drupal, FOSSLC Summer Camp 2010
Intro to Theming Drupal, FOSSLC Summer Camp 2010Emma Jane Hogbin Westby
 
Absolute Beginners Guide to Drupal
Absolute Beginners Guide to DrupalAbsolute Beginners Guide to Drupal
Absolute Beginners Guide to DrupalRod Martin
 
NewBCamp09: Turning your design into a WordPress Theme
NewBCamp09: Turning your design into a WordPress ThemeNewBCamp09: Turning your design into a WordPress Theme
NewBCamp09: Turning your design into a WordPress ThemeAdam Darowski
 
Drupal 8 - Corso frontend development
Drupal 8 - Corso frontend developmentDrupal 8 - Corso frontend development
Drupal 8 - Corso frontend developmentsparkfabrik
 
Arizona WP - Building a WordPress Theme
Arizona WP - Building a WordPress ThemeArizona WP - Building a WordPress Theme
Arizona WP - Building a WordPress Themecertainstrings
 
WordPress Theme Development: Part 2
WordPress Theme Development: Part 2WordPress Theme Development: Part 2
WordPress Theme Development: Part 2Josh Lee
 
Ts drupal6 module development v0.2
Ts   drupal6 module development v0.2Ts   drupal6 module development v0.2
Ts drupal6 module development v0.2Confiz
 
Introduction to WordPress Theme Development
Introduction to WordPress Theme DevelopmentIntroduction to WordPress Theme Development
Introduction to WordPress Theme DevelopmentSitdhibong Laokok
 
PyGrunn 2017 - Django Performance Unchained - slides
PyGrunn 2017 - Django Performance Unchained - slidesPyGrunn 2017 - Django Performance Unchained - slides
PyGrunn 2017 - Django Performance Unchained - slidesArtur Barseghyan
 
One-hour Drupal 8 Theming
One-hour Drupal 8 ThemingOne-hour Drupal 8 Theming
One-hour Drupal 8 ThemingMediacurrent
 
Getting started with drupal 8 code
Getting started with drupal 8 codeGetting started with drupal 8 code
Getting started with drupal 8 codeForum One
 

What's hot (20)

Drupal 8 introduction to theming
Drupal 8  introduction to themingDrupal 8  introduction to theming
Drupal 8 introduction to theming
 
Converting (X)HTML/CSS template to Drupal 7 Theme
Converting (X)HTML/CSS template to Drupal 7 ThemeConverting (X)HTML/CSS template to Drupal 7 Theme
Converting (X)HTML/CSS template to Drupal 7 Theme
 
8 things to know about theming in drupal 8
8 things to know about theming in drupal 88 things to know about theming in drupal 8
8 things to know about theming in drupal 8
 
Design to Theme @ CMSExpo
Design to Theme @ CMSExpoDesign to Theme @ CMSExpo
Design to Theme @ CMSExpo
 
Drupal 8 theming deep dive
Drupal 8 theming deep diveDrupal 8 theming deep dive
Drupal 8 theming deep dive
 
Building a Custom Theme in Drupal 8
Building a Custom Theme in Drupal 8Building a Custom Theme in Drupal 8
Building a Custom Theme in Drupal 8
 
Learning PHP for Drupal Theming, DC Chicago 2009
Learning PHP for Drupal Theming, DC Chicago 2009Learning PHP for Drupal Theming, DC Chicago 2009
Learning PHP for Drupal Theming, DC Chicago 2009
 
Intro to Theming Drupal, FOSSLC Summer Camp 2010
Intro to Theming Drupal, FOSSLC Summer Camp 2010Intro to Theming Drupal, FOSSLC Summer Camp 2010
Intro to Theming Drupal, FOSSLC Summer Camp 2010
 
Absolute Beginners Guide to Drupal
Absolute Beginners Guide to DrupalAbsolute Beginners Guide to Drupal
Absolute Beginners Guide to Drupal
 
NewBCamp09: Turning your design into a WordPress Theme
NewBCamp09: Turning your design into a WordPress ThemeNewBCamp09: Turning your design into a WordPress Theme
NewBCamp09: Turning your design into a WordPress Theme
 
Drupal 8 - Corso frontend development
Drupal 8 - Corso frontend developmentDrupal 8 - Corso frontend development
Drupal 8 - Corso frontend development
 
Arizona WP - Building a WordPress Theme
Arizona WP - Building a WordPress ThemeArizona WP - Building a WordPress Theme
Arizona WP - Building a WordPress Theme
 
Building Drupal 6 Theme
Building Drupal 6 ThemeBuilding Drupal 6 Theme
Building Drupal 6 Theme
 
WordPress Theme Development: Part 2
WordPress Theme Development: Part 2WordPress Theme Development: Part 2
WordPress Theme Development: Part 2
 
Ts drupal6 module development v0.2
Ts   drupal6 module development v0.2Ts   drupal6 module development v0.2
Ts drupal6 module development v0.2
 
Introduction to WordPress Theme Development
Introduction to WordPress Theme DevelopmentIntroduction to WordPress Theme Development
Introduction to WordPress Theme Development
 
PyGrunn 2017 - Django Performance Unchained - slides
PyGrunn 2017 - Django Performance Unchained - slidesPyGrunn 2017 - Django Performance Unchained - slides
PyGrunn 2017 - Django Performance Unchained - slides
 
Drupal Front End PHP
Drupal Front End PHPDrupal Front End PHP
Drupal Front End PHP
 
One-hour Drupal 8 Theming
One-hour Drupal 8 ThemingOne-hour Drupal 8 Theming
One-hour Drupal 8 Theming
 
Getting started with drupal 8 code
Getting started with drupal 8 codeGetting started with drupal 8 code
Getting started with drupal 8 code
 

Similar to A look at Drupal 7 Theming

Drupal7 themeing changes and inheritence
Drupal7 themeing changes and inheritenceDrupal7 themeing changes and inheritence
Drupal7 themeing changes and inheritenceAimee Maree Forsstrom
 
Creating and Theming Custom Content Types
Creating and Theming Custom Content TypesCreating and Theming Custom Content Types
Creating and Theming Custom Content Typesheatherrumd
 
Theming tips and tricks
Theming tips and tricksTheming tips and tricks
Theming tips and tricksaaroncouch
 
Drupal Theming for Developers
Drupal Theming for DevelopersDrupal Theming for Developers
Drupal Theming for DevelopersIan Carnaghan
 
7 Theming in Drupal
7 Theming in Drupal7 Theming in Drupal
7 Theming in DrupalWingston
 
Creating and Theming Custom Content Types
Creating and Theming Custom Content TypesCreating and Theming Custom Content Types
Creating and Theming Custom Content Typesheatherrumd
 
Twig for Drupal @ Frontendunited Amsterdam 2012
Twig for Drupal @ Frontendunited Amsterdam 2012Twig for Drupal @ Frontendunited Amsterdam 2012
Twig for Drupal @ Frontendunited Amsterdam 2012Rene Bakx
 
Theming Drupal: Beyond the Look and Feel
Theming Drupal: Beyond the Look and FeelTheming Drupal: Beyond the Look and Feel
Theming Drupal: Beyond the Look and FeelChris Albrecht
 
Creating Drupal A Module
Creating Drupal A ModuleCreating Drupal A Module
Creating Drupal A Modulearcaneadam
 
Drupal Themes
Drupal ThemesDrupal Themes
Drupal Themesakosh
 
SynapseIndia drupal presentation on drupal best practices
SynapseIndia drupal  presentation on drupal best practicesSynapseIndia drupal  presentation on drupal best practices
SynapseIndia drupal presentation on drupal best practicesSynapseindiappsdevelopment
 
Drupal 8: frontend development
Drupal 8: frontend developmentDrupal 8: frontend development
Drupal 8: frontend developmentsparkfabrik
 
Drupal 6 Overview
Drupal 6 OverviewDrupal 6 Overview
Drupal 6 OverviewRyan Cross
 

Similar to A look at Drupal 7 Theming (20)

Drupal7 themeing changes and inheritence
Drupal7 themeing changes and inheritenceDrupal7 themeing changes and inheritence
Drupal7 themeing changes and inheritence
 
Drupal theme development
Drupal theme developmentDrupal theme development
Drupal theme development
 
Creating and Theming Custom Content Types
Creating and Theming Custom Content TypesCreating and Theming Custom Content Types
Creating and Theming Custom Content Types
 
Theming tips and tricks
Theming tips and tricksTheming tips and tricks
Theming tips and tricks
 
Drupal Theme Development
Drupal Theme DevelopmentDrupal Theme Development
Drupal Theme Development
 
Drupal - Introduction to Drupal Creating Modules
Drupal - Introduction to Drupal Creating ModulesDrupal - Introduction to Drupal Creating Modules
Drupal - Introduction to Drupal Creating Modules
 
Drupal
DrupalDrupal
Drupal
 
Drupal Theming for Developers
Drupal Theming for DevelopersDrupal Theming for Developers
Drupal Theming for Developers
 
7 Theming in Drupal
7 Theming in Drupal7 Theming in Drupal
7 Theming in Drupal
 
Creating and Theming Custom Content Types
Creating and Theming Custom Content TypesCreating and Theming Custom Content Types
Creating and Theming Custom Content Types
 
Twig for Drupal @ Frontendunited Amsterdam 2012
Twig for Drupal @ Frontendunited Amsterdam 2012Twig for Drupal @ Frontendunited Amsterdam 2012
Twig for Drupal @ Frontendunited Amsterdam 2012
 
Theming Drupal: Beyond the Look and Feel
Theming Drupal: Beyond the Look and FeelTheming Drupal: Beyond the Look and Feel
Theming Drupal: Beyond the Look and Feel
 
Readme
ReadmeReadme
Readme
 
Drupal theming
Drupal themingDrupal theming
Drupal theming
 
Creating Drupal A Module
Creating Drupal A ModuleCreating Drupal A Module
Creating Drupal A Module
 
Drupal Themes
Drupal ThemesDrupal Themes
Drupal Themes
 
SynapseIndia drupal presentation on drupal best practices
SynapseIndia drupal  presentation on drupal best practicesSynapseIndia drupal  presentation on drupal best practices
SynapseIndia drupal presentation on drupal best practices
 
Drupal 6 Theming
Drupal 6 ThemingDrupal 6 Theming
Drupal 6 Theming
 
Drupal 8: frontend development
Drupal 8: frontend developmentDrupal 8: frontend development
Drupal 8: frontend development
 
Drupal 6 Overview
Drupal 6 OverviewDrupal 6 Overview
Drupal 6 Overview
 

More from Aimee Maree Forsstrom

DOM and Accessibility API Communication
DOM and Accessibility API CommunicationDOM and Accessibility API Communication
DOM and Accessibility API CommunicationAimee Maree Forsstrom
 
Accessiblity 101 and JavaScript Frameworks
Accessiblity 101 and JavaScript Frameworks Accessiblity 101 and JavaScript Frameworks
Accessiblity 101 and JavaScript Frameworks Aimee Maree Forsstrom
 
The Good, The Bad, The Voiceover - ios Accessibility
The Good, The Bad, The Voiceover - ios AccessibilityThe Good, The Bad, The Voiceover - ios Accessibility
The Good, The Bad, The Voiceover - ios AccessibilityAimee Maree Forsstrom
 
Javascript Framework Acessibiliity Review
Javascript Framework Acessibiliity ReviewJavascript Framework Acessibiliity Review
Javascript Framework Acessibiliity ReviewAimee Maree Forsstrom
 
Diversity through iOS Development - App Camp 4 Girls
Diversity through iOS Development - App Camp 4 GirlsDiversity through iOS Development - App Camp 4 Girls
Diversity through iOS Development - App Camp 4 GirlsAimee Maree Forsstrom
 
Waving an Open Source Flag in Australian Government
Waving an Open Source Flag in Australian GovernmentWaving an Open Source Flag in Australian Government
Waving an Open Source Flag in Australian GovernmentAimee Maree Forsstrom
 
Govhack - Collections of World War One Connecting the Dots
Govhack - Collections of World War One Connecting the DotsGovhack - Collections of World War One Connecting the Dots
Govhack - Collections of World War One Connecting the DotsAimee Maree Forsstrom
 
Accessibility with Joomla [on a budget]
Accessibility with Joomla [on a budget]Accessibility with Joomla [on a budget]
Accessibility with Joomla [on a budget]Aimee Maree Forsstrom
 
FirefoxOS and its use of Linux (a deep dive into Gonk architecture)
FirefoxOS and its use of Linux (a deep dive into Gonk architecture)FirefoxOS and its use of Linux (a deep dive into Gonk architecture)
FirefoxOS and its use of Linux (a deep dive into Gonk architecture)Aimee Maree Forsstrom
 
Introduction to Python - Training for Kids
Introduction to Python - Training for KidsIntroduction to Python - Training for Kids
Introduction to Python - Training for KidsAimee Maree Forsstrom
 
UK Communications Bill Proposed Changes 2012
UK Communications Bill Proposed Changes 2012UK Communications Bill Proposed Changes 2012
UK Communications Bill Proposed Changes 2012Aimee Maree Forsstrom
 

More from Aimee Maree Forsstrom (20)

AI - PAST, PRESENT, FUTURE.pptx
AI - PAST, PRESENT, FUTURE.pptxAI - PAST, PRESENT, FUTURE.pptx
AI - PAST, PRESENT, FUTURE.pptx
 
Pioneering Technology - My Story
Pioneering Technology - My StoryPioneering Technology - My Story
Pioneering Technology - My Story
 
DOM and Accessibility API Communication
DOM and Accessibility API CommunicationDOM and Accessibility API Communication
DOM and Accessibility API Communication
 
Machine Learning ate my homework
Machine Learning ate my homeworkMachine Learning ate my homework
Machine Learning ate my homework
 
Accessiblity 101 and JavaScript Frameworks
Accessiblity 101 and JavaScript Frameworks Accessiblity 101 and JavaScript Frameworks
Accessiblity 101 and JavaScript Frameworks
 
Accessibility, SEO and Joomla
Accessibility, SEO and JoomlaAccessibility, SEO and Joomla
Accessibility, SEO and Joomla
 
The Good, The Bad, The Voiceover - ios Accessibility
The Good, The Bad, The Voiceover - ios AccessibilityThe Good, The Bad, The Voiceover - ios Accessibility
The Good, The Bad, The Voiceover - ios Accessibility
 
Javascript Framework Acessibiliity Review
Javascript Framework Acessibiliity ReviewJavascript Framework Acessibiliity Review
Javascript Framework Acessibiliity Review
 
DeCoupling Drupal
DeCoupling DrupalDeCoupling Drupal
DeCoupling Drupal
 
Diversity through iOS Development - App Camp 4 Girls
Diversity through iOS Development - App Camp 4 GirlsDiversity through iOS Development - App Camp 4 Girls
Diversity through iOS Development - App Camp 4 Girls
 
Waving an Open Source Flag in Australian Government
Waving an Open Source Flag in Australian GovernmentWaving an Open Source Flag in Australian Government
Waving an Open Source Flag in Australian Government
 
Cyber Terrorism or Terrible Code
Cyber Terrorism or Terrible Code Cyber Terrorism or Terrible Code
Cyber Terrorism or Terrible Code
 
Govhack - Collections of World War One Connecting the Dots
Govhack - Collections of World War One Connecting the DotsGovhack - Collections of World War One Connecting the Dots
Govhack - Collections of World War One Connecting the Dots
 
Accessibility with Joomla [on a budget]
Accessibility with Joomla [on a budget]Accessibility with Joomla [on a budget]
Accessibility with Joomla [on a budget]
 
FirefoxOS and its use of Linux (a deep dive into Gonk architecture)
FirefoxOS and its use of Linux (a deep dive into Gonk architecture)FirefoxOS and its use of Linux (a deep dive into Gonk architecture)
FirefoxOS and its use of Linux (a deep dive into Gonk architecture)
 
Introduction to Python - Training for Kids
Introduction to Python - Training for KidsIntroduction to Python - Training for Kids
Introduction to Python - Training for Kids
 
UK Communications Bill Proposed Changes 2012
UK Communications Bill Proposed Changes 2012UK Communications Bill Proposed Changes 2012
UK Communications Bill Proposed Changes 2012
 
Welcome to the World of Trolls
Welcome to the World of TrollsWelcome to the World of Trolls
Welcome to the World of Trolls
 
Drupal’s growth
Drupal’s growthDrupal’s growth
Drupal’s growth
 
Help me help you learn
Help me help you learnHelp me help you learn
Help me help you learn
 

Recently uploaded

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 

Recently uploaded (20)

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 

A look at Drupal 7 Theming

  • 1. A look at how Drupal themes are created Learning Drupal Sydney
  • 2. In a CMS a presentation layer displays the content to website visitors based on a set of templates “A theme is a collection of files that define the presentation layer.” – Drupal.org Think of it as the index.html with static content replaced by PHP variables
  • 3. No, you can use modules to change the layout of a page or section of a page. An example of some modules are; Panels http://drupal.org/project/panels Display Suite http://drupal.org/project/ds Skinr http://drupal.org/project/skinr Block Class http://drupal.org/project/block_class But they only change the layout of pages not the frame of the site
  • 4.
  • 5.
  • 6.
  • 7. PHP variables are turned into the needed HTML calls
  • 8.
  • 9. You can change your sites theme from the “Appearance” menu option in Drupal 7 a themes can consist of a couple of .tpl files (page.tpl.php, node.tpl.php) and on .css file a themes can consist of many .tpl files and multipule .css and .js files
  • 10. /sites/all/themes [correct] /themes [not correct] Never over write core themes files that live in the base folder of Drupal, this is called hacking core Don’t take a copy of a core theme to create another theme use a contributed theme
  • 11. All Drupal themes must have an info.php file, one css file .info (required) > think of this as the template configuration file All other files depend on how much you want to customise the look of Drupal A typical theme consists of page.tpl.php, node.tpl.php, block.tpl.php, comment.tpl.php, style.css http://drupal.org/node/190815 lists all core templates
  • 12. Think of it as the themes configuration file Must be named the same as the theme folder Required in a theme Tells Drupal about the theme Declares themes name name = Ourtheme Declares what version of Drupal core = 6.x Declares css files stylesheets[all][] = style.css Declares javascript files scripts[] = scripts/superfish.js Declares regions regions[content] = Main content Declares features features[] = logo
  • 13.
  • 14. Think of it as the content between <head> </head> Prints out all needed CSS and JavaScript files Does not need to be included in a file as it will inherit the Drupal core html.tpl.php file Allows for more granular control
  • 15.
  • 16. Think of it as the content between <body> </body> You print your regions in your page.tpl.php <?php print render ($page['preface']); ?> Its the frame of your website Create’s the page layout, were content is printed, menu, search, sidebars…
  • 17.
  • 18. Themes all nodes in the site Prints out the output of $content variable in page.tpl.php Controls what all node pages look like, can be overwritten by specific templates targeting the node id or content type. Think of nodes as the content on the page <div id=“content”> <h1>…</h1> <p>…</p> </div> Can theme all nodes node.tpl.php Can theme a specific node node--nodeid.tpl.php
  • 19.
  • 20. Themes all blocks or themes a specific block Allows you to wrap more HTML and CSS code around the block or remove some HTML Can theme all blocks block.tpl.php Can theme all blocks in a specific region block--region.tpl.php Can themes blocks produced by modules block--module.tpl.php
  • 21.
  • 22.
  • 23.
  • 24. Themes all regions or themes a specific region Allows you to wrap more HTML and CSS code around the region area Allows you to style the menu region and then the sidebar region to have more control of Drupal out-put Can theme all regions region.tpl.php Can theme a specific region region—search.tpl.php
  • 25.
  • 26. Used to theme individual fields Will theme all the fields that are of that type Must flush cache when adding and removing templates For example you create an image field and use that across three content types, the field theme will apply the field.tpl.php to all three content types field.tpl.php field--field-type.tpl.php field--field-name.tpl.php field--content-type.tpl.php field--field-name--content-type.tpl.php
  • 27.
  • 28. Themes the way that comments look Can theme individual comments and the comment area wrapper Can theme the comment wrapper comment-wrapper.tpl.php Can theme individual comments comment.tpl.php
  • 29.
  • 30.
  • 31.
  • 32. Themes how your “Site offline” page looks Enables you to control how your maintenance page looks enables a more professional look When you turn your site offline into maintenance mode if you don’t have a specific maintenance theme the default Drupal maintenance template will display
  • 33. You can only use page.tpl.php variables on page.tpl.php as you can only use node variables on node.tpl.php  This means not all variables can be printed on all templates, variables are template specific  Theme inheritance applies, more about that…
  • 34.
  • 35. 1. Drupal core applies its own .tpl.php files they are called first 2. Drupal modules apply their own .tpl.php files these are applied second and over write any css calls that exist in core tpl.php files 3. Your theme has its own .tpl.php files these are applied last and over write calls in core tpl.php files and module tpl.php files 4. Your theme has the final say!
  • 36. theme tpl.php files Theme Wins /sites/all/themes/ourtheme/templates/node.tpl.php module node.tpl.php gets overridden by the module tpl.php files them node.tpl.php /sites/all/modules/examplemodule/node.tpl.php Core core tpl.php files node.tpl.php gets overridden by the /modules/node/node.tpl.php modules node.tpl.php
  • 37. File does not exist Core Wins There is no file to overwrite the /sites/all/themes/ourtheme/templates/? core so it is used to create the output File does not exist There is no file to /sites/all/modules/examplemodule/? overwrite the core tpl file core tpl.php files Core html.tpl.php is applied to the /modules/node/html.tpl.php layout
  • 38. Templates within your own Theme can also be overwritten by other templates in your theme this allows you to be specific with your template target Drupal.org describes it as “Template suggestions are made based on these factors  Listed from the most specific template to the least.  Drupal will use the most specific template it finds.”
  • 39. Specific Wins node--nodeid.tpl.php node—nodeid.tpl.php will apply to the specific node that matches the id number node--type.tpl.php node--type.tpl.php will apply to all nodes of a specific content type node.tpl.php will node.tpl.php be called to theme all Drupal nodes
  • 40. 1. Drupal core applies its own .css file this is called first 2. Drupal modules apply their own .css files these are applied second and over write any css calls that exist in core css files 3. Your theme has its own .css files these are applied last and over write calls in core css files and module css files 4. Your theme has the final say!
  • 41. If a theme .css file has the same class call, then it will be overwritten by the theme css Theme Wins h1 { font-size: 3em; } module css calls gets overridden by the theme css If a module .css file has the same class call, then it calls will be overwritten by the module css h1 { font-size: 2em; } Core css calls Core css files style a header tag get overridden by the modules if h1 { font-size: 1.6em; } there is a file with the same name style.css
  • 42. You see a CSS class coming from module/node/node.css? Don’t change the module/node/node.css file Do copy the css call and paste it into your theme.css file You want to use your own css to style a module? Don’t change sites/all/modules/name/module.css file Do take a copy of the css file, place a copy of the module.css file into your theme folder and enter stylesheets[all][] = modulestyle.css into your themes info file Do flush cache
  • 43.
  • 44.
  • 45. There are 42 different .tpl files in Drupal7 core modules folder. /modules/modulename/*.tpl.php Each one of these can be copied and placed in your own theme to overwrite the output /sites/all/theme/yourtheme/templates/*.tpl.php If a contributed module has a .tpl file this can be copied into your theme folder and it will overwrite the .tpl in the modules folder /sites/all/modules/example/*.tpl.php
  • 46. 1. Take a copy of the .tpl.php file we need from the module 2. Move the copy to our themes templates folder, this can be under the folder theme/templates/*.tpl.php or under the root of the theme folder theme/*.tpl.php 1. Flush cache or flush the theme registry to see if we can notice the changes on the website
  • 47. Theme the layout of a specific content type; If you want to theme the news content type, you would create;  node-news.tpl.php  node-content-type-machine-name.tpl.php
  • 48. Take a copy of node.tpl.php  Rename it to node—contenttype.tpl.php  Add the styling you want  If you want to change the layout then you can use devel to locate the field names and print them out separately  To do this you need to delete the $content variable print render replace it with calls to the specific fields print render($content['field_gallery_image']);
  • 49. <div class="content"> <?php // First we hide the comments and links now so that we can render them later. hide($content['comments']); hide($content['links']); // Then we print the content. Comments and links not included here. print render($content); ?> </div> // Then we print the links and comments separately <?php print render($content['links']); ?> <?php print render($content['comments']); ?>.
  • 50. You can use the Devel module to tell you all the fields you have available on a content type  Devel render will display the name you need to call to print that field in the tpl file Field variables will print out the array so if there is 1 it will print 1 or if there is 3 it will print out 3, one after the other, an example three images files uploaded to a node will print out three times by calling the field
  • 51. <div class="imageElement"> <?php print render($content['field_gallery_image']); print render($content['field_galleryimagecaption']); ?> </div> print render($content['field_namehere']);
  • 52.
  • 53. It is a good first start  Look for a theme that has the desired layout  Download a theme from the Drupal.org website, and apply it to your website  You need to enable the theme and set it as the default
  • 54. If your going to change a contributed theme; 1. Take a copy of the theme folder and give it a new name 2. Rename the x.info file to match the name of the folder 3. Open up the theme and change some of the CSS styles 4. Change any calls to image files in the theme and replace them with your own
  • 55.  A base theme gives you a good starting point for creating your own theme  Its best to use a base theme otherwise you may miss needed Drupal PHP variables  It helps reduce development time  Takes care of a lot of the starting work in creating your own theme from scratch  You can use a responsive design aka Adaptive base theme is a responsive design which means you don’t need to write the media query calls
  • 56.
  • 57. Sub themes inherit templates, css, js and functions from there base theme  This means;  If the base theme is based on the 960 grid system the sub theme will as well  If the base theme is an adaptive theme, the sub theme will be as well  It saves us time of building these features into our themes
  • 58. Sub themes must always have the core theme enabled in the Drupal appearance area  The subtheme must be enabled and set as default  Each base theme has its own documentation, but, generally we take a copy of one of the start sub-themes and we rename it to our new theme name
  • 59. The best way to get your personalised site But you need to understand and know the Drupal theme variables and structure So often best to use a Base Theme
  • 60. Learning Drupal Sydney Aimee Maree Forsstrom – Drupal Solution Architect