SlideShare a Scribd company logo
Drupal themingWilson Wingston Sharonwingston.sharon@gmail.com
When you access a Drupal website, what you see on the screen is the result of the site's active theme files. As the theme files call the data, the files also set the styling, position, and placement of the content on your screen.
How a CMS functions - againText and pointers to other kinds of content are stored in the database; that data is then dynamically retrieved, composed, and presented to a user in response to a request sent from a web browser. Drupal functions  with the themes playing the crucial role in the formatting and presentation of the contents
7 Theming in Drupal
Remember1. You Can Theme It AllThe Drupal system allows you to specify different page templates for different purposes on your site. 2. Build with BlocksThe process of activating modules and assigning blocks to regions on the pages is one of the most basic and most important skillsEach of the blocks in the system, whether created by modules or manually created by the system administrator, can be themed individually, if you so desire.3. Intercept and Override
Intercept and overrideseveral opportunities for you to affect the output prior to the data's arrival fron DB on the viewer's screen.The best practice approach to customizing themes involves intercepting and overriding files and styles—not altering the core.  By choosing to affect the system's output at the highest levels of Drupal's processes, we leave the core in a purer state.
Files making up a themeblock.tpl.php – Defines the appearance of the blocks on the page.box.tpl.php – Defines a specific format—a box used to frame things (like comments in the Bluemarine theme).comment.tpl.php – Defines the appearance of the comments which follow items.logo.png – An image file containing the logo used in the theme.node.tpl.php – Defines the appearance of the nodes.page.tpl.php – This is the primary theme file. style.css – The style sheet for this theme.
Finding Themes onlineGo to drupal.org themes section and download themes for your drupal version.Do not use conflicting versions. Eg for drupal 6.x versions, download themes with 6.x in the file name.Do not use alpha versions. Use beta ones at your own risk.Download your theme. You’ll get it usually as a tar.gz
Setting up themesRemember the sites/all/modules folder where we put the downloaded modules?Go to c:/wamp/www/mysite/sites/all and make a folder called themes.Extract your theme into that folder.Go to administer>>themesClick the radio box for default on theme you like and click ok.
configureClick the configure link, make sure you are on global settings.Here, you can set up theme options for all themes you might have. These override individual theme options.Now click on the theme links you see, all enabled themes show up as a link and you can give them individual settings too.Some themes have a lot of individual settings that you can exploit.
ZenZen is the ultimate starting theme for Drupal. If you are building your own standards-compliant theme, you will find it much easier to start with ZenSupport: Providing or receiving support for any theme you develop in Drupal’s normal support forums can be difficult.Bug fixes & updates: Occasionally there will be bugs found in Zen core. If you have modified any of Zen’s core files, it will be difficult for you to incorporate any of those bug fixes into your modified version of Zen.
Theming trick –Create a custom user login barDisplay a compact, nice user login form that can fit in one line.Once user is logged in, It will display a welcome message and a couple of helpful links.We’ll do this in the garland theme. So go to admin>>themes and move back to garland.Garland files will be in c:\\..\mysite\themes\garland
ApproachDrupal is very powerful, it's so flexible that you have many ways to do things. That's why a 5 minutes of thinking is very recommended before we get our hands dirty.a separate function, call it garland_user_bar(). It decide, and return HTML for the login form, or the welcome message.page.tpl.php, we will place a call to this function somewhere where it gets displayed in the top.Now we have the logic, after that we will write some CSS to style it, to change how it looks
Open the folder styling files. You can copy paste code from here to where I tell you.First open the page.tpl.php from garland root theme folder.Add <div id="navigation"><?php print garland_user_bar() ?></div>  from 1. page.tpl.code on line 16, just under the body tag. Save and close.
Adding the php functionOpen themes/garland/template.php Append the contents of 2.template.php.txt I provided to the end of this file.function garland_user_bar() {  global $user;                                                                  $output = '';  if (!$user->uid) {                                                               $output .= drupal_get_form('user_login_block');                              }                                                                              else {                                                                           $output .= t('<p class="user-info">Hi !user, welcome back.</p>', array('!user' => theme('username', $user)));       $output .= theme('item_list', array(      l(t('Your account'), 'user/'.$user->uid, array('title' => t('Edit your account'))),      l(t('Sign out'), 'logout')));  }      $output = '<div id="user-bar">'.$output.'</div>';  return $output;}
stylingOpen themes/garland/page.tpl.phpAdd contents of “3.stylecode.txt” after line 15, before the </head tag.<style type="text/css" media="all">@import "<?php print base_path() . path_to_theme() ?>/user_bar.css";</style>Copy user_bar.css into the garland theme root.
Wingston.sharon@gmail.comwww.workshopindia.comworkshopindia@gmail.comqueries@workshopindia.com

More Related Content

What's hot (20)

PPT
Drupal - Introduction to Drupal Creating Modules
Vibrant Technologies & Computers
 
PPTX
Daughter Themes
Paul Bearne
 
PPTX
Web development and web design with seo
Rajat Anand
 
PPTX
Drupalcamp Atlanta 2010 Design-to-Theme
Mediacurrent
 
PPT
Web1
Kumar
 
PPT
Web1
amrith879
 
PDF
Firstborn child theme word camp presentation - atlanta 2013
Evan Mullins
 
ODP
DrupalEasy: Intro to Theme Development
ultimike
 
PDF
Approaches To WordPress Theme Development
Catch Themes
 
PPTX
Intro to Plugin Development, Miami WordCamp, 2015
topher1kenobe
 
PPTX
Introduction to WordPress Child Theming, WordCamp Kansas City, 2015
topher1kenobe
 
PPT
Drupal 6 Theming
merlinofchaos
 
ZIP
Drupal Themes: Past, present and future
Nicolas Borda
 
PDF
Upgrading a Plone 3 Theme for Plone 4: Beyond the Basics
Heather Wozniak
 
PPTX
HTML Start Up - Introduction to HTML
Grayzon Gonzales, LPT
 
PDF
Feathertheme
Lilyana Vankova
 
PPT
Aleph500 How we made it our own
Bill Drew
 
PPTX
10 Steps to Becoming a WordPress Theme Ninja
Tony Cecala, Ph.D.
 
KEY
Html intro
Robyn Overstreet
 
Drupal - Introduction to Drupal Creating Modules
Vibrant Technologies & Computers
 
Daughter Themes
Paul Bearne
 
Web development and web design with seo
Rajat Anand
 
Drupalcamp Atlanta 2010 Design-to-Theme
Mediacurrent
 
Web1
Kumar
 
Web1
amrith879
 
Firstborn child theme word camp presentation - atlanta 2013
Evan Mullins
 
DrupalEasy: Intro to Theme Development
ultimike
 
Approaches To WordPress Theme Development
Catch Themes
 
Intro to Plugin Development, Miami WordCamp, 2015
topher1kenobe
 
Introduction to WordPress Child Theming, WordCamp Kansas City, 2015
topher1kenobe
 
Drupal 6 Theming
merlinofchaos
 
Drupal Themes: Past, present and future
Nicolas Borda
 
Upgrading a Plone 3 Theme for Plone 4: Beyond the Basics
Heather Wozniak
 
HTML Start Up - Introduction to HTML
Grayzon Gonzales, LPT
 
Feathertheme
Lilyana Vankova
 
Aleph500 How we made it our own
Bill Drew
 
10 Steps to Becoming a WordPress Theme Ninja
Tony Cecala, Ph.D.
 
Html intro
Robyn Overstreet
 

Similar to 7 Theming in Drupal (20)

PDF
Drupal theming
Philip Norton
 
PDF
Design to Theme @ CMSExpo
Emma Jane Hogbin Westby
 
ODP
Drupal Theme Development - DrupalCon Chicago 2011
Ryan Price
 
PDF
Nanocon Taiwan
John Albin Wilkins
 
PDF
Intro to Theming Drupal, FOSSLC Summer Camp 2010
Emma Jane Hogbin Westby
 
PDF
Drupal Front End PHP
Emma Jane Hogbin Westby
 
PDF
Learning PHP for Drupal Theming, DC Chicago 2009
Emma Jane Hogbin Westby
 
PPT
SynapseIndia drupal presentation on drupal best practices
Synapseindiappsdevelopment
 
PDF
New Adventures in Drupal Theming
John Albin Wilkins
 
PDF
Drupal theming - a practical approach (European Drupal Days 2015)
Eugenio Minardi
 
PDF
Demystifying drupal 7 theming
Anthony Ogbonna
 
KEY
Advanced theming
tlattimore
 
KEY
Advanced theming
DrupalcampAtlanta2012
 
PPTX
Theming Drupal: Beyond the Look and Feel
Chris Albrecht
 
PPTX
Theming Drupal 6 - An Introduction to the Basics
Erik Baldwin
 
PPTX
Drupal Theming For Beginners – Danté SELF 2010
Mediacurrent
 
PDF
Let's Zen! (Stop Theming From Scratch)
Chris Charlton
 
PPTX
Drupal theme development
Fortune Innovations Dublin
 
KEY
PSD to Drupal - Introductory Drupal Theming
sheenadonnelly
 
PPTX
Drupal Theme Development
Web Development Montreal
 
Drupal theming
Philip Norton
 
Design to Theme @ CMSExpo
Emma Jane Hogbin Westby
 
Drupal Theme Development - DrupalCon Chicago 2011
Ryan Price
 
Nanocon Taiwan
John Albin Wilkins
 
Intro to Theming Drupal, FOSSLC Summer Camp 2010
Emma Jane Hogbin Westby
 
Drupal Front End PHP
Emma Jane Hogbin Westby
 
Learning PHP for Drupal Theming, DC Chicago 2009
Emma Jane Hogbin Westby
 
SynapseIndia drupal presentation on drupal best practices
Synapseindiappsdevelopment
 
New Adventures in Drupal Theming
John Albin Wilkins
 
Drupal theming - a practical approach (European Drupal Days 2015)
Eugenio Minardi
 
Demystifying drupal 7 theming
Anthony Ogbonna
 
Advanced theming
tlattimore
 
Advanced theming
DrupalcampAtlanta2012
 
Theming Drupal: Beyond the Look and Feel
Chris Albrecht
 
Theming Drupal 6 - An Introduction to the Basics
Erik Baldwin
 
Drupal Theming For Beginners – Danté SELF 2010
Mediacurrent
 
Let's Zen! (Stop Theming From Scratch)
Chris Charlton
 
Drupal theme development
Fortune Innovations Dublin
 
PSD to Drupal - Introductory Drupal Theming
sheenadonnelly
 
Drupal Theme Development
Web Development Montreal
 
Ad

More from Wingston (20)

PPTX
OpenCV @ Droidcon 2012
Wingston
 
PPTX
05 content providers - Android
Wingston
 
PPTX
04 activities - Android
Wingston
 
PPTX
03 layouts & ui design - Android
Wingston
 
PPTX
02 hello world - Android
Wingston
 
PPTX
01 introduction & setup - Android
Wingston
 
PPTX
OpenCV with android
Wingston
 
PPTX
C game programming - SDL
Wingston
 
PPTX
C programming - Pointers
Wingston
 
PPTX
Introduction to Basic C programming 02
Wingston
 
PPT
Introduction to Basic C programming 01
Wingston
 
PPTX
Linux – an introduction
Wingston
 
PPTX
Embedded linux
Wingston
 
PPTX
04 Arduino Peripheral Interfacing
Wingston
 
PPTX
03 analogue anrduino fundamentals
Wingston
 
PPTX
02 General Purpose Input - Output on the Arduino
Wingston
 
PPTX
Introduction to the Arduino
Wingston
 
PPTX
4.content mgmt
Wingston
 
PPTX
8 Web Practices for Drupal
Wingston
 
PPTX
6 Special Howtos for Drupal
Wingston
 
OpenCV @ Droidcon 2012
Wingston
 
05 content providers - Android
Wingston
 
04 activities - Android
Wingston
 
03 layouts & ui design - Android
Wingston
 
02 hello world - Android
Wingston
 
01 introduction & setup - Android
Wingston
 
OpenCV with android
Wingston
 
C game programming - SDL
Wingston
 
C programming - Pointers
Wingston
 
Introduction to Basic C programming 02
Wingston
 
Introduction to Basic C programming 01
Wingston
 
Linux – an introduction
Wingston
 
Embedded linux
Wingston
 
04 Arduino Peripheral Interfacing
Wingston
 
03 analogue anrduino fundamentals
Wingston
 
02 General Purpose Input - Output on the Arduino
Wingston
 
Introduction to the Arduino
Wingston
 
4.content mgmt
Wingston
 
8 Web Practices for Drupal
Wingston
 
6 Special Howtos for Drupal
Wingston
 
Ad

7 Theming in Drupal

  • 2. When you access a Drupal website, what you see on the screen is the result of the site's active theme files. As the theme files call the data, the files also set the styling, position, and placement of the content on your screen.
  • 3. How a CMS functions - againText and pointers to other kinds of content are stored in the database; that data is then dynamically retrieved, composed, and presented to a user in response to a request sent from a web browser. Drupal functions with the themes playing the crucial role in the formatting and presentation of the contents
  • 5. Remember1. You Can Theme It AllThe Drupal system allows you to specify different page templates for different purposes on your site. 2. Build with BlocksThe process of activating modules and assigning blocks to regions on the pages is one of the most basic and most important skillsEach of the blocks in the system, whether created by modules or manually created by the system administrator, can be themed individually, if you so desire.3. Intercept and Override
  • 6. Intercept and overrideseveral opportunities for you to affect the output prior to the data's arrival fron DB on the viewer's screen.The best practice approach to customizing themes involves intercepting and overriding files and styles—not altering the core. By choosing to affect the system's output at the highest levels of Drupal's processes, we leave the core in a purer state.
  • 7. Files making up a themeblock.tpl.php – Defines the appearance of the blocks on the page.box.tpl.php – Defines a specific format—a box used to frame things (like comments in the Bluemarine theme).comment.tpl.php – Defines the appearance of the comments which follow items.logo.png – An image file containing the logo used in the theme.node.tpl.php – Defines the appearance of the nodes.page.tpl.php – This is the primary theme file. style.css – The style sheet for this theme.
  • 8. Finding Themes onlineGo to drupal.org themes section and download themes for your drupal version.Do not use conflicting versions. Eg for drupal 6.x versions, download themes with 6.x in the file name.Do not use alpha versions. Use beta ones at your own risk.Download your theme. You’ll get it usually as a tar.gz
  • 9. Setting up themesRemember the sites/all/modules folder where we put the downloaded modules?Go to c:/wamp/www/mysite/sites/all and make a folder called themes.Extract your theme into that folder.Go to administer>>themesClick the radio box for default on theme you like and click ok.
  • 10. configureClick the configure link, make sure you are on global settings.Here, you can set up theme options for all themes you might have. These override individual theme options.Now click on the theme links you see, all enabled themes show up as a link and you can give them individual settings too.Some themes have a lot of individual settings that you can exploit.
  • 11. ZenZen is the ultimate starting theme for Drupal. If you are building your own standards-compliant theme, you will find it much easier to start with ZenSupport: Providing or receiving support for any theme you develop in Drupal’s normal support forums can be difficult.Bug fixes & updates: Occasionally there will be bugs found in Zen core. If you have modified any of Zen’s core files, it will be difficult for you to incorporate any of those bug fixes into your modified version of Zen.
  • 12. Theming trick –Create a custom user login barDisplay a compact, nice user login form that can fit in one line.Once user is logged in, It will display a welcome message and a couple of helpful links.We’ll do this in the garland theme. So go to admin>>themes and move back to garland.Garland files will be in c:\\..\mysite\themes\garland
  • 13. ApproachDrupal is very powerful, it's so flexible that you have many ways to do things. That's why a 5 minutes of thinking is very recommended before we get our hands dirty.a separate function, call it garland_user_bar(). It decide, and return HTML for the login form, or the welcome message.page.tpl.php, we will place a call to this function somewhere where it gets displayed in the top.Now we have the logic, after that we will write some CSS to style it, to change how it looks
  • 14. Open the folder styling files. You can copy paste code from here to where I tell you.First open the page.tpl.php from garland root theme folder.Add <div id="navigation"><?php print garland_user_bar() ?></div> from 1. page.tpl.code on line 16, just under the body tag. Save and close.
  • 15. Adding the php functionOpen themes/garland/template.php Append the contents of 2.template.php.txt I provided to the end of this file.function garland_user_bar() {  global $user;                                                                  $output = '';  if (!$user->uid) {                                                               $output .= drupal_get_form('user_login_block');                              }                                                                              else {                                                                           $output .= t('<p class="user-info">Hi !user, welcome back.</p>', array('!user' => theme('username', $user)));       $output .= theme('item_list', array(      l(t('Your account'), 'user/'.$user->uid, array('title' => t('Edit your account'))),      l(t('Sign out'), 'logout')));  }      $output = '<div id="user-bar">'.$output.'</div>';  return $output;}
  • 16. stylingOpen themes/garland/page.tpl.phpAdd contents of “3.stylecode.txt” after line 15, before the </head tag.<style type="text/css" media="all">@import "<?php print base_path() . path_to_theme() ?>/user_bar.css";</style>Copy user_bar.css into the garland theme root.