SlideShare a Scribd company logo
1 of 29
Converting (X)HTML/CSS
template to DRUPAL 7 theme
By: Adolfo G. Nasol – http://danreb.com




                            http://cavhost.com
Additional option for creating
DRUPAL theme
   As I said, this will give us another
    flavour on creating a Drupal 7 theme,
    Drupal THEMERS usually create
    themes using a base starter theme
    and modify to fit into their needs, with
    this, we are creating themes base on
    your existing (X)HTML structures and
    its corresponding CSS files.


                           http://cavhost.com
What Designer(s) and Noob
think about Drupal Themeing?
 Noob assume that Drupal theming is
  complicated and its overwhelming
 They try to look at several Base starter
  themes and got confused (OMG, I've
  better stay with WordPress / Joomla)
 Better create my own CMS huh!




                        http://cavhost.com
What should you do?
   Never fear!, because its possible to
    create your own theme base on your
    designs and concepts and base on
    your existing (X)HTML and CSS
    structures and layout.




                         http://cavhost.com
What should we learn?
 Step by step process for converting
  your (X)HTML/CSS template into
  Drupal 7 theme
 Finds the location of Drupal’s default
  template files (.TPL files ) and modify
  as you need it.
 Some examples and a demonstration




                        http://cavhost.com
Basic knowledge required
 You need to know how to install and
  setup a Drupal site.
 (X)HTML/CSS – of course!
 Basic knowledge in PHP scripts
 A little knowledge in JavaScript
  (jQuery)
 Drupal Terminology (nodes, blocks,
  regions and etc...)

                       http://cavhost.com
Why not just use a Base Starter
theme?
   Hey, instructions for creating a Drupal
    theme usually tells us to start with an
    existing theme or base theme and
    customize it to fit to our needs. Do you
    have problem with that? Are you
    against it?

    - NOPE!


                          http://cavhost.com
Then you’d better explain!,
What’s the problem?
   Avoiding frustration(specially for noob).
    Existing themes and base theme often
    include options and features that you don't
    actually needs
      - lots of regions
      - bunch of CSS files that makes it work
      - So many features that make your site
    slow.

This is fine if that's what you need but also
 result in very complex template files and
 bloated CSS.
                              http://cavhost.com
Then you’d better explain!,
What’s the problem?
   To help us learn how Drupal
    theming actually works and gain
    better understanding of the theming
    system.




                         http://cavhost.com
Drupal 7 themes




                  http://cavhost.com
Other valid reason?
   Your client gives you an existing
    (x)html/css template and he wants you
    to use that for their drupal website.
    Using a base theme for this is a lot
    harder because you already have
    existing html structures and layout,
    CSS class and ID’s won’t match and
    your frustration begins. Instead of
    using a base theme, its better to
    convert that existing template directly
    into a DRUPAL 7 theme.
                          http://cavhost.com
Step by step process for
Converting (X)HTML/CSS to
Drupal 7 theme.
Step 1 - Prepare the template

Prepare your existing (X)HTML/CSS
  template, make sure all files are
  intact and working properly, test it in
  the browser if it is working fine and
  bug free.



                        http://cavhost.com
Step by step process for
Converting (X)HTML/CSS to
Drupal 7 theme.
Adjust the following as a part of
  preparation process

      Rename the logo as logo.png - Drupal looks
       for "logo.png" files inside a drupal themes
       and use it as default logo. If the logo is inside
       the images folder, copy that logo into the
       directory where the index.html file resides,
       they must be in the same level.



                                http://cavhost.com
Step by step process for
Converting (X)HTML/CSS to
Drupal 7 theme. (X)HTML/CSS layouts,
   Analyze your existing
       each section of the template will need to be
       converted into DRUPAL block regions, tools
       such as firebug can help you or even an
       HTML editing software such as Adobe
       Dreamweaver.
      Take note of the sections in the html
       template, we will use this sections as block
       region and we will need to define it in
       themename.info file.




                              http://cavhost.com
Step by step process for
Converting (X)HTML/CSS to
Drupal 7Create the folder for your theme
  Step 2 –
           theme.

   - Create a folder inside sites/all/themes/
       directory, this will be the name of your
       Drupal theme, for example, if you
       created a folder named "mytheme"
       then your directory shall be
       "sites/all/themes/mytheme"




                            http://cavhost.com
Step by step process for
Converting (X)HTML/CSS to
Drupal 7Copy the files in themes folder
  Step 3 –
           theme.

   - Copy all the files in your (X)HTML/CSS
      templates into the directory you've just
      created "sites/all/themes/mytheme" ,
      make sure to include all the HTML
      files, CSS, Images, JavaScript's and
      other assets and etc...




                           http://cavhost.com
Step by step process for
Converting (X)HTML/CSS to
Drupal –7 theme.
  Step 4 Create themename.info

  -   Create "themename.info" file, name must
      be the same with your folder name, theme
      folder named "mytheme“ must have
      “mytheme.info” inside it.
  -   Declare the following: name, description,
      core, engine, stylesheets, javascript’s,
      and regions.

  Visit http://drupal.org/node/171205 for
      information on .INFO file, look on
      bartik.info files for working examples,
      copy if necessary and update the
      information as needed.
                            http://cavhost.com
Step by step process for
Converting (X)HTML/CSS to
Drupal 7Create page.tpl.php
  Step 5 –
           theme.

     Duplicate your main html file, usually
      "index.html“ or “index.htm” and rename the
      copy as page.tpl.php




                            http://cavhost.com
Step by step process for
Converting (X)HTML/CSS to
Drupal 7Copy all other TPL files you want to use
  Step 6 –
           theme.
        and overrides (optional)

       Copy the template files you want to override
        and edit the mark-up (html.tpl.php,
        node.tpl.php, block.tpl.php), put this to your
        theme folder, this way you can edit the file
        without hacking the original in the core.

    Please check http://drupal.org/node/190815 for
       list of core templates. Also check core
       modules folder for available .TPL files.
                                http://cavhost.com
Step by step process for
Converting (X)HTML/CSS to
Drupal 7Edit page.tpl.php
  Step 7 –
           theme.

     Open your page.tpl.php and edit, remove all
      tags starting from DOCTYPE up to opening
      <body> tag.
     Scroll down to the bottom of the page.tpl.php
      and also remove the closing </body> body
      tag and the closing </html> html tag.




                             http://cavhost.com
Step by step process for
Converting (X)HTML/CSS to
Drupal 7Check and declare all the reference for
  Step 8 –
           theme.
       the CSS and JS file into .INFO file.

      Take note of all references to CSS file and JS
       file in the header section of the (X)HTML file
       and make sure you declare this into your
       .INFO file.
      Note that if your html template used jQuery
       library, you don’t need to include this to
       themename.info because Drupal already
       comes with jQuery library.


                               http://cavhost.com
Step by step process for
Converting (X)HTML/CSS to
Drupal 7 theme. regions
  Step 9– Insert your block

    Start Inserting all your regions, any part of
     your page you want to be editable in the
     Drupal interface(via Blocks) need to be
     converted to a region.
  Code example:
  <?php if ($page['sidebar_second']): ?>
   <div id="sidebar-1" class="sidebar-1">
    <?php print render($page['sidebar_second']); ?>
   </div> <!-- /#sidebar-1 -->
  <?php endif; ?>

                                 http://cavhost.com
Step by step process for
Converting (X)HTML/CSS to
Drupal – Insert variables you want to use
  Step 10 7 theme.
      Start Inserting all the necessary variables you want to
       use and you need in the proper spot where you want to
       show it on your page. Some of the most common
       variable in page.tpl.php
            $site_name
            $logo
            $title
            $main_menu
            $secondary_menu
            $breadcrumbs
            $tabs
            $messages

        Variables are inserted using the Render API, information can be found
              here -> http://drupal.org/node/930760

         Example of printing tabs <?php print render($tabs); ?>


                                           http://cavhost.com
Step by step process for
Converting (X)HTML/CSS to
Drupal 7 Adjust your CSS
  Step 11 –
            theme.

     Adjust your CSS and override Drupal default
      style sheet as you need to fit your design into
      your Drupal site. Firebug can help you a lot
      with this to properly find the correct element
      class and id’s that you want to override.




                              http://cavhost.com
Step by step process for
Converting (X)HTML/CSS to
Drupal 7 theme.
  Step 12 – Test and Done!

     And were Done!
  Note:
  Were done with the basic, its enough for you to be able to
      convert an existing html/css template to Drupal 7
      theme.

  Advance theming use more .TPL files and requires you to
      create custom PHP code in template.php files, you
      need to learn how template hooks works and all the
      available pre-process functions. More information here:
      http://drupal.org/node/341628.

                                  http://cavhost.com
Example of theme hook
  Adding external stylesheets ( template.php )

  Code:

  <?php
  function mytheme_preprocess_html(&$variables) {
  drupal_add_css('http://fonts.googleapis.com/css?family=News+Cy
       cle', array('type' => 'external'));
  }
  ?>




                                    http://cavhost.com
Theme Developer module
  Themer's usually use theme developer
     module that can be downloaded at
     http://drupal.org/project/devel_themer
  You can view template suggestion and
     existing variables value with the help of
     this module




                          http://cavhost.com
Helper PHP function
  If you don't want to install theme developer modules, you can use the
        following PHP function to inspect your page for variables and
        array values:
  Code:
  <pre>
    <?php var_dump($var); ?>
  </pre>

  Or with this one

  <pre>
  <?php
   $vars = get_defined_vars();
   print_r($vars);
  ?>
  </pre>

  For more info, please visit: http://drupal.org/node/348916


                                        http://cavhost.com
Happy DRUPAL Theming!
   Adolfo G. Nasol
   Mobile: 09195951276
   Blog: http://danreb.com
   Website: http://cavhost.com
   Email: adolfo@danreb.com

More power, PHDUG – Philippine
  Drupal User Group! 2012

                       http://cavhost.com

More Related Content

What's hot

Drupal theming - a practical approach (European Drupal Days 2015)
Drupal theming - a practical approach (European Drupal Days 2015)Drupal theming - a practical approach (European Drupal Days 2015)
Drupal theming - a practical approach (European Drupal Days 2015)Eugenio Minardi
 
Drupal 8: Theming
Drupal 8: ThemingDrupal 8: Theming
Drupal 8: Themingdrubb
 
Grok Drupal (7) Theming
Grok Drupal (7) ThemingGrok Drupal (7) Theming
Grok Drupal (7) ThemingPINGV
 
Drupal 8 - Corso frontend development
Drupal 8 - Corso frontend developmentDrupal 8 - Corso frontend development
Drupal 8 - Corso frontend developmentsparkfabrik
 
Introduction to Drupal (7) Theming
Introduction to Drupal (7) ThemingIntroduction to Drupal (7) Theming
Introduction to Drupal (7) ThemingRobert Carr
 
Absolute Beginners Guide to Drupal
Absolute Beginners Guide to DrupalAbsolute Beginners Guide to Drupal
Absolute Beginners Guide to DrupalRod Martin
 
Grok Drupal (7) Theming - 2011 Feb update
Grok Drupal (7) Theming - 2011 Feb updateGrok Drupal (7) Theming - 2011 Feb update
Grok Drupal (7) Theming - 2011 Feb updateLaura Scott
 
Drupal 7 Theme System
Drupal 7 Theme SystemDrupal 7 Theme System
Drupal 7 Theme SystemPeter Arato
 
Theme guru's (Moodle 2 Edition)
Theme guru's (Moodle 2 Edition)Theme guru's (Moodle 2 Edition)
Theme guru's (Moodle 2 Edition)Julian Ridden
 
Drupal 7 Theming - what's new
Drupal 7 Theming - what's newDrupal 7 Theming - what's new
Drupal 7 Theming - what's newMarek Sotak
 
One-hour Drupal 8 Theming
One-hour Drupal 8 ThemingOne-hour Drupal 8 Theming
One-hour Drupal 8 ThemingMediacurrent
 
Twig for Drupal 8 and PHP | Presented at OC Drupal
Twig for Drupal 8 and PHP | Presented at OC DrupalTwig for Drupal 8 and PHP | Presented at OC Drupal
Twig for Drupal 8 and PHP | Presented at OC Drupalwebbywe
 
Drupal Themes
Drupal ThemesDrupal Themes
Drupal Themesakosh
 
D7 theming what's new - London
D7 theming what's new - LondonD7 theming what's new - London
D7 theming what's new - LondonMarek Sotak
 
Customizing WordPress Themes
Customizing WordPress ThemesCustomizing WordPress Themes
Customizing WordPress ThemesLaura Hartwig
 
Atomicant Drupal 6 Theming
Atomicant Drupal 6 ThemingAtomicant Drupal 6 Theming
Atomicant Drupal 6 ThemingMarek Sotak
 
Theme Kickstart
Theme KickstartTheme Kickstart
Theme KickstartPeter
 

What's hot (19)

Drupal theming - a practical approach (European Drupal Days 2015)
Drupal theming - a practical approach (European Drupal Days 2015)Drupal theming - a practical approach (European Drupal Days 2015)
Drupal theming - a practical approach (European Drupal Days 2015)
 
Drupal 8: Theming
Drupal 8: ThemingDrupal 8: Theming
Drupal 8: Theming
 
Grok Drupal (7) Theming
Grok Drupal (7) ThemingGrok Drupal (7) Theming
Grok Drupal (7) Theming
 
Drupal 8 - Corso frontend development
Drupal 8 - Corso frontend developmentDrupal 8 - Corso frontend development
Drupal 8 - Corso frontend development
 
Introduction to Drupal (7) Theming
Introduction to Drupal (7) ThemingIntroduction to Drupal (7) Theming
Introduction to Drupal (7) Theming
 
A look at Drupal 7 Theming
A look at Drupal 7 ThemingA look at Drupal 7 Theming
A look at Drupal 7 Theming
 
Absolute Beginners Guide to Drupal
Absolute Beginners Guide to DrupalAbsolute Beginners Guide to Drupal
Absolute Beginners Guide to Drupal
 
Grok Drupal (7) Theming - 2011 Feb update
Grok Drupal (7) Theming - 2011 Feb updateGrok Drupal (7) Theming - 2011 Feb update
Grok Drupal (7) Theming - 2011 Feb update
 
Design to Theme @ CMSExpo
Design to Theme @ CMSExpoDesign to Theme @ CMSExpo
Design to Theme @ CMSExpo
 
Drupal 7 Theme System
Drupal 7 Theme SystemDrupal 7 Theme System
Drupal 7 Theme System
 
Theme guru's (Moodle 2 Edition)
Theme guru's (Moodle 2 Edition)Theme guru's (Moodle 2 Edition)
Theme guru's (Moodle 2 Edition)
 
Drupal 7 Theming - what's new
Drupal 7 Theming - what's newDrupal 7 Theming - what's new
Drupal 7 Theming - what's new
 
One-hour Drupal 8 Theming
One-hour Drupal 8 ThemingOne-hour Drupal 8 Theming
One-hour Drupal 8 Theming
 
Twig for Drupal 8 and PHP | Presented at OC Drupal
Twig for Drupal 8 and PHP | Presented at OC DrupalTwig for Drupal 8 and PHP | Presented at OC Drupal
Twig for Drupal 8 and PHP | Presented at OC Drupal
 
Drupal Themes
Drupal ThemesDrupal Themes
Drupal Themes
 
D7 theming what's new - London
D7 theming what's new - LondonD7 theming what's new - London
D7 theming what's new - London
 
Customizing WordPress Themes
Customizing WordPress ThemesCustomizing WordPress Themes
Customizing WordPress Themes
 
Atomicant Drupal 6 Theming
Atomicant Drupal 6 ThemingAtomicant Drupal 6 Theming
Atomicant Drupal 6 Theming
 
Theme Kickstart
Theme KickstartTheme Kickstart
Theme Kickstart
 

Viewers also liked

Converting Static Html To Drupal Theme
Converting Static Html To Drupal ThemeConverting Static Html To Drupal Theme
Converting Static Html To Drupal ThemeRyan Cross
 
Introduction to Drupal 7 News section and home page block with views
Introduction to Drupal 7  News section and home page block with viewsIntroduction to Drupal 7  News section and home page block with views
Introduction to Drupal 7 News section and home page block with viewsKalin Chernev
 
From Photoshop to Drupal Theme (DrupalCon San Francisco 2010)
From Photoshop to Drupal Theme (DrupalCon San Francisco 2010)From Photoshop to Drupal Theme (DrupalCon San Francisco 2010)
From Photoshop to Drupal Theme (DrupalCon San Francisco 2010)Four Kitchens
 
Triduo Sr. Angela Vallese_2 giorno eng
Triduo Sr. Angela Vallese_2 giorno engTriduo Sr. Angela Vallese_2 giorno eng
Triduo Sr. Angela Vallese_2 giorno engMaike Loes
 
Audacity oinarrizkoa
Audacity oinarrizkoaAudacity oinarrizkoa
Audacity oinarrizkoaKatalogador
 
Secrets & Lies
Secrets & LiesSecrets & Lies
Secrets & LiesSam Baksh
 
Triduo Sr Angela Vallese_3 giorno eng
Triduo Sr Angela Vallese_3 giorno engTriduo Sr Angela Vallese_3 giorno eng
Triduo Sr Angela Vallese_3 giorno engMaike Loes
 
Formulación inorgánica
Formulación inorgánicaFormulación inorgánica
Formulación inorgánicabesteiroalonso
 
Preliminary slide show
Preliminary slide showPreliminary slide show
Preliminary slide showstoliros
 
Heather's composition
Heather's compositionHeather's composition
Heather's compositionheather114
 
Mult –step equations
Mult –step equationsMult –step equations
Mult –step equationsuniv harvard
 
My name is brian magnant
My name is brian magnantMy name is brian magnant
My name is brian magnantmagnantbrian
 
Gmm 17 gennaio 2016 ita
Gmm 17 gennaio 2016 itaGmm 17 gennaio 2016 ita
Gmm 17 gennaio 2016 itaMaike Loes
 
Cor animatore-missionario-04
Cor animatore-missionario-04Cor animatore-missionario-04
Cor animatore-missionario-04Maike Loes
 
ฉันเหมือนใคร สุขศึกษา ม.1 7
ฉันเหมือนใคร สุขศึกษา ม.1 7ฉันเหมือนใคร สุขศึกษา ม.1 7
ฉันเหมือนใคร สุขศึกษา ม.1 7ai17
 
Triduo Sr. Angela Vallese_3 giorno ita
Triduo Sr. Angela Vallese_3 giorno itaTriduo Sr. Angela Vallese_3 giorno ita
Triduo Sr. Angela Vallese_3 giorno itaMaike Loes
 

Viewers also liked (20)

Converting Static Html To Drupal Theme
Converting Static Html To Drupal ThemeConverting Static Html To Drupal Theme
Converting Static Html To Drupal Theme
 
Introduction to Drupal 7 News section and home page block with views
Introduction to Drupal 7  News section and home page block with viewsIntroduction to Drupal 7  News section and home page block with views
Introduction to Drupal 7 News section and home page block with views
 
From Photoshop to Drupal Theme (DrupalCon San Francisco 2010)
From Photoshop to Drupal Theme (DrupalCon San Francisco 2010)From Photoshop to Drupal Theme (DrupalCon San Francisco 2010)
From Photoshop to Drupal Theme (DrupalCon San Francisco 2010)
 
Triduo Sr. Angela Vallese_2 giorno eng
Triduo Sr. Angela Vallese_2 giorno engTriduo Sr. Angela Vallese_2 giorno eng
Triduo Sr. Angela Vallese_2 giorno eng
 
Audacity oinarrizkoa
Audacity oinarrizkoaAudacity oinarrizkoa
Audacity oinarrizkoa
 
Secrets & Lies
Secrets & LiesSecrets & Lies
Secrets & Lies
 
Triduo Sr Angela Vallese_3 giorno eng
Triduo Sr Angela Vallese_3 giorno engTriduo Sr Angela Vallese_3 giorno eng
Triduo Sr Angela Vallese_3 giorno eng
 
Formulación inorgánica
Formulación inorgánicaFormulación inorgánica
Formulación inorgánica
 
L tthon
L tthonL tthon
L tthon
 
Preliminary slide show
Preliminary slide showPreliminary slide show
Preliminary slide show
 
Pencil Parable
Pencil  ParablePencil  Parable
Pencil Parable
 
Presentation1
Presentation1Presentation1
Presentation1
 
Heather's composition
Heather's compositionHeather's composition
Heather's composition
 
Mult –step equations
Mult –step equationsMult –step equations
Mult –step equations
 
My name is brian magnant
My name is brian magnantMy name is brian magnant
My name is brian magnant
 
Gmm 17 gennaio 2016 ita
Gmm 17 gennaio 2016 itaGmm 17 gennaio 2016 ita
Gmm 17 gennaio 2016 ita
 
Cor animatore-missionario-04
Cor animatore-missionario-04Cor animatore-missionario-04
Cor animatore-missionario-04
 
Presentation
PresentationPresentation
Presentation
 
ฉันเหมือนใคร สุขศึกษา ม.1 7
ฉันเหมือนใคร สุขศึกษา ม.1 7ฉันเหมือนใคร สุขศึกษา ม.1 7
ฉันเหมือนใคร สุขศึกษา ม.1 7
 
Triduo Sr. Angela Vallese_3 giorno ita
Triduo Sr. Angela Vallese_3 giorno itaTriduo Sr. Angela Vallese_3 giorno ita
Triduo Sr. Angela Vallese_3 giorno ita
 

Similar to Converting (X)HTML/CSS template to Drupal 7 Theme

7 Theming in Drupal
7 Theming in Drupal7 Theming in Drupal
7 Theming in DrupalWingston
 
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...LinnAlexandra
 
Introduction To Drupal
Introduction To DrupalIntroduction To Drupal
Introduction To DrupalLauren Roth
 
Theming tips and tricks
Theming tips and tricksTheming tips and tricks
Theming tips and tricksaaroncouch
 
Theming Drupal 6 - An Introduction to the Basics
Theming Drupal 6 - An Introduction to the BasicsTheming Drupal 6 - An Introduction to the Basics
Theming Drupal 6 - An Introduction to the BasicsErik Baldwin
 
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
 
Drupal Theme Development - DrupalCon Chicago 2011
Drupal Theme Development - DrupalCon Chicago 2011Drupal Theme Development - DrupalCon Chicago 2011
Drupal Theme Development - DrupalCon Chicago 2011Ryan Price
 
Cms drupal installation & configuration anil mishra
Cms drupal installation & configuration   anil mishraCms drupal installation & configuration   anil mishra
Cms drupal installation & configuration anil mishraAnil Mishra
 
Drupal 7x Installation - Introduction to Drupal Concepts
Drupal 7x Installation - Introduction to Drupal ConceptsDrupal 7x Installation - Introduction to Drupal Concepts
Drupal 7x Installation - Introduction to Drupal ConceptsMicky Metts
 
Drupal Now! - Introduction to Drupal
Drupal Now! - Introduction to DrupalDrupal Now! - Introduction to Drupal
Drupal Now! - Introduction to DrupalAlozie Nwosu
 
Drupal7 Theming session on the occassion of Drupal7 release party in Delhi NCR
Drupal7 Theming session on the occassion of  Drupal7 release party in Delhi NCRDrupal7 Theming session on the occassion of  Drupal7 release party in Delhi NCR
Drupal7 Theming session on the occassion of Drupal7 release party in Delhi NCRGaurav Mishra
 

Similar to Converting (X)HTML/CSS template to Drupal 7 Theme (20)

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 theming
Drupal themingDrupal theming
Drupal theming
 
7 Theming in Drupal
7 Theming in Drupal7 Theming in Drupal
7 Theming in Drupal
 
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...
 
Introduction To Drupal
Introduction To DrupalIntroduction To Drupal
Introduction To Drupal
 
Drupal
DrupalDrupal
Drupal
 
Theming tips and tricks
Theming tips and tricksTheming tips and tricks
Theming tips and tricks
 
Theming Drupal 6 - An Introduction to the Basics
Theming Drupal 6 - An Introduction to the BasicsTheming Drupal 6 - An Introduction to the Basics
Theming Drupal 6 - An Introduction to the Basics
 
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 8: frontend development
Drupal 8: frontend developmentDrupal 8: frontend development
Drupal 8: frontend development
 
Building Drupal 6 Theme
Building Drupal 6 ThemeBuilding Drupal 6 Theme
Building Drupal 6 Theme
 
Drupal 6 Overview
Drupal 6 OverviewDrupal 6 Overview
Drupal 6 Overview
 
Drupal Theming
Drupal Theming Drupal Theming
Drupal Theming
 
Drupal Theme Development - DrupalCon Chicago 2011
Drupal Theme Development - DrupalCon Chicago 2011Drupal Theme Development - DrupalCon Chicago 2011
Drupal Theme Development - DrupalCon Chicago 2011
 
Drupal
DrupalDrupal
Drupal
 
Cms drupal installation & configuration anil mishra
Cms drupal installation & configuration   anil mishraCms drupal installation & configuration   anil mishra
Cms drupal installation & configuration anil mishra
 
Drupal 7x Installation - Introduction to Drupal Concepts
Drupal 7x Installation - Introduction to Drupal ConceptsDrupal 7x Installation - Introduction to Drupal Concepts
Drupal 7x Installation - Introduction to Drupal Concepts
 
Drupal Now! - Introduction to Drupal
Drupal Now! - Introduction to DrupalDrupal Now! - Introduction to Drupal
Drupal Now! - Introduction to Drupal
 
Drupal7 Theming session on the occassion of Drupal7 release party in Delhi NCR
Drupal7 Theming session on the occassion of  Drupal7 release party in Delhi NCRDrupal7 Theming session on the occassion of  Drupal7 release party in Delhi NCR
Drupal7 Theming session on the occassion of Drupal7 release party in Delhi NCR
 

More from Adolfo Nasol

Drupal debugging tips
Drupal debugging tipsDrupal debugging tips
Drupal debugging tipsAdolfo Nasol
 
Mysql cheatsheet - Part 2
Mysql cheatsheet - Part 2Mysql cheatsheet - Part 2
Mysql cheatsheet - Part 2Adolfo Nasol
 
Managing drupal views in code
Managing drupal views in codeManaging drupal views in code
Managing drupal views in codeAdolfo Nasol
 
Event Registration System Part 2
Event Registration System Part 2Event Registration System Part 2
Event Registration System Part 2Adolfo Nasol
 
Events Registration System Part 1
Events Registration System Part 1Events Registration System Part 1
Events Registration System Part 1Adolfo Nasol
 
Installing mandriva linux mandriva community wiki
Installing mandriva linux   mandriva community wikiInstalling mandriva linux   mandriva community wiki
Installing mandriva linux mandriva community wikiAdolfo Nasol
 
Drush for drupal website builder
Drush for drupal website builderDrush for drupal website builder
Drush for drupal website builderAdolfo Nasol
 
Creating Drupal 7 subtheme
Creating Drupal 7 subthemeCreating Drupal 7 subtheme
Creating Drupal 7 subthemeAdolfo Nasol
 
Chs nc2 reviewer - with oral questioning
Chs nc2 reviewer - with oral questioningChs nc2 reviewer - with oral questioning
Chs nc2 reviewer - with oral questioningAdolfo Nasol
 
Operating System Concepts : Reports
Operating System Concepts : ReportsOperating System Concepts : Reports
Operating System Concepts : ReportsAdolfo Nasol
 
Drupal Checklist for Site Builder and Web admin
Drupal Checklist for Site Builder and Web adminDrupal Checklist for Site Builder and Web admin
Drupal Checklist for Site Builder and Web adminAdolfo Nasol
 

More from Adolfo Nasol (14)

Drupal debugging tips
Drupal debugging tipsDrupal debugging tips
Drupal debugging tips
 
Mysql cheatsheet - Part 2
Mysql cheatsheet - Part 2Mysql cheatsheet - Part 2
Mysql cheatsheet - Part 2
 
Mysql cheatsheet
Mysql cheatsheetMysql cheatsheet
Mysql cheatsheet
 
Managing drupal views in code
Managing drupal views in codeManaging drupal views in code
Managing drupal views in code
 
Event Registration System Part 2
Event Registration System Part 2Event Registration System Part 2
Event Registration System Part 2
 
Events Registration System Part 1
Events Registration System Part 1Events Registration System Part 1
Events Registration System Part 1
 
Installing mandriva linux mandriva community wiki
Installing mandriva linux   mandriva community wikiInstalling mandriva linux   mandriva community wiki
Installing mandriva linux mandriva community wiki
 
Drush for drupal website builder
Drush for drupal website builderDrush for drupal website builder
Drush for drupal website builder
 
Research methods
Research methodsResearch methods
Research methods
 
Personality
PersonalityPersonality
Personality
 
Creating Drupal 7 subtheme
Creating Drupal 7 subthemeCreating Drupal 7 subtheme
Creating Drupal 7 subtheme
 
Chs nc2 reviewer - with oral questioning
Chs nc2 reviewer - with oral questioningChs nc2 reviewer - with oral questioning
Chs nc2 reviewer - with oral questioning
 
Operating System Concepts : Reports
Operating System Concepts : ReportsOperating System Concepts : Reports
Operating System Concepts : Reports
 
Drupal Checklist for Site Builder and Web admin
Drupal Checklist for Site Builder and Web adminDrupal Checklist for Site Builder and Web admin
Drupal Checklist for Site Builder and Web admin
 

Recently uploaded

International Business Environments and Operations 16th Global Edition test b...
International Business Environments and Operations 16th Global Edition test b...International Business Environments and Operations 16th Global Edition test b...
International Business Environments and Operations 16th Global Edition test b...ssuserf63bd7
 
Innovation Conference 5th March 2024.pdf
Innovation Conference 5th March 2024.pdfInnovation Conference 5th March 2024.pdf
Innovation Conference 5th March 2024.pdfrichard876048
 
Memorándum de Entendimiento (MoU) entre Codelco y SQM
Memorándum de Entendimiento (MoU) entre Codelco y SQMMemorándum de Entendimiento (MoU) entre Codelco y SQM
Memorándum de Entendimiento (MoU) entre Codelco y SQMVoces Mineras
 
The-Ethical-issues-ghhhhhhhhjof-Byjus.pptx
The-Ethical-issues-ghhhhhhhhjof-Byjus.pptxThe-Ethical-issues-ghhhhhhhhjof-Byjus.pptx
The-Ethical-issues-ghhhhhhhhjof-Byjus.pptxmbikashkanyari
 
8447779800, Low rate Call girls in Saket Delhi NCR
8447779800, Low rate Call girls in Saket Delhi NCR8447779800, Low rate Call girls in Saket Delhi NCR
8447779800, Low rate Call girls in Saket Delhi NCRashishs7044
 
Appkodes Tinder Clone Script with Customisable Solutions.pptx
Appkodes Tinder Clone Script with Customisable Solutions.pptxAppkodes Tinder Clone Script with Customisable Solutions.pptx
Appkodes Tinder Clone Script with Customisable Solutions.pptxappkodes
 
8447779800, Low rate Call girls in Uttam Nagar Delhi NCR
8447779800, Low rate Call girls in Uttam Nagar Delhi NCR8447779800, Low rate Call girls in Uttam Nagar Delhi NCR
8447779800, Low rate Call girls in Uttam Nagar Delhi NCRashishs7044
 
Market Sizes Sample Report - 2024 Edition
Market Sizes Sample Report - 2024 EditionMarket Sizes Sample Report - 2024 Edition
Market Sizes Sample Report - 2024 EditionMintel Group
 
Cybersecurity Awareness Training Presentation v2024.03
Cybersecurity Awareness Training Presentation v2024.03Cybersecurity Awareness Training Presentation v2024.03
Cybersecurity Awareness Training Presentation v2024.03DallasHaselhorst
 
Buy gmail accounts.pdf Buy Old Gmail Accounts
Buy gmail accounts.pdf Buy Old Gmail AccountsBuy gmail accounts.pdf Buy Old Gmail Accounts
Buy gmail accounts.pdf Buy Old Gmail AccountsBuy Verified Accounts
 
Chapter 9 PPT 4th edition.pdf internal audit
Chapter 9 PPT 4th edition.pdf internal auditChapter 9 PPT 4th edition.pdf internal audit
Chapter 9 PPT 4th edition.pdf internal auditNhtLNguyn9
 
Darshan Hiranandani [News About Next CEO].pdf
Darshan Hiranandani [News About Next CEO].pdfDarshan Hiranandani [News About Next CEO].pdf
Darshan Hiranandani [News About Next CEO].pdfShashank Mehta
 
Independent Call Girls Andheri Nightlaila 9967584737
Independent Call Girls Andheri Nightlaila 9967584737Independent Call Girls Andheri Nightlaila 9967584737
Independent Call Girls Andheri Nightlaila 9967584737Riya Pathan
 
Flow Your Strategy at Flight Levels Day 2024
Flow Your Strategy at Flight Levels Day 2024Flow Your Strategy at Flight Levels Day 2024
Flow Your Strategy at Flight Levels Day 2024Kirill Klimov
 
Call Girls Contact Number Andheri 9920874524
Call Girls Contact Number Andheri 9920874524Call Girls Contact Number Andheri 9920874524
Call Girls Contact Number Andheri 9920874524najka9823
 
8447779800, Low rate Call girls in Kotla Mubarakpur Delhi NCR
8447779800, Low rate Call girls in Kotla Mubarakpur Delhi NCR8447779800, Low rate Call girls in Kotla Mubarakpur Delhi NCR
8447779800, Low rate Call girls in Kotla Mubarakpur Delhi NCRashishs7044
 
Organizational Structure Running A Successful Business
Organizational Structure Running A Successful BusinessOrganizational Structure Running A Successful Business
Organizational Structure Running A Successful BusinessSeta Wicaksana
 

Recently uploaded (20)

International Business Environments and Operations 16th Global Edition test b...
International Business Environments and Operations 16th Global Edition test b...International Business Environments and Operations 16th Global Edition test b...
International Business Environments and Operations 16th Global Edition test b...
 
Innovation Conference 5th March 2024.pdf
Innovation Conference 5th March 2024.pdfInnovation Conference 5th March 2024.pdf
Innovation Conference 5th March 2024.pdf
 
Memorándum de Entendimiento (MoU) entre Codelco y SQM
Memorándum de Entendimiento (MoU) entre Codelco y SQMMemorándum de Entendimiento (MoU) entre Codelco y SQM
Memorándum de Entendimiento (MoU) entre Codelco y SQM
 
The-Ethical-issues-ghhhhhhhhjof-Byjus.pptx
The-Ethical-issues-ghhhhhhhhjof-Byjus.pptxThe-Ethical-issues-ghhhhhhhhjof-Byjus.pptx
The-Ethical-issues-ghhhhhhhhjof-Byjus.pptx
 
8447779800, Low rate Call girls in Saket Delhi NCR
8447779800, Low rate Call girls in Saket Delhi NCR8447779800, Low rate Call girls in Saket Delhi NCR
8447779800, Low rate Call girls in Saket Delhi NCR
 
Corporate Profile 47Billion Information Technology
Corporate Profile 47Billion Information TechnologyCorporate Profile 47Billion Information Technology
Corporate Profile 47Billion Information Technology
 
Appkodes Tinder Clone Script with Customisable Solutions.pptx
Appkodes Tinder Clone Script with Customisable Solutions.pptxAppkodes Tinder Clone Script with Customisable Solutions.pptx
Appkodes Tinder Clone Script with Customisable Solutions.pptx
 
8447779800, Low rate Call girls in Uttam Nagar Delhi NCR
8447779800, Low rate Call girls in Uttam Nagar Delhi NCR8447779800, Low rate Call girls in Uttam Nagar Delhi NCR
8447779800, Low rate Call girls in Uttam Nagar Delhi NCR
 
Market Sizes Sample Report - 2024 Edition
Market Sizes Sample Report - 2024 EditionMarket Sizes Sample Report - 2024 Edition
Market Sizes Sample Report - 2024 Edition
 
Enjoy ➥8448380779▻ Call Girls In Sector 18 Noida Escorts Delhi NCR
Enjoy ➥8448380779▻ Call Girls In Sector 18 Noida Escorts Delhi NCREnjoy ➥8448380779▻ Call Girls In Sector 18 Noida Escorts Delhi NCR
Enjoy ➥8448380779▻ Call Girls In Sector 18 Noida Escorts Delhi NCR
 
Cybersecurity Awareness Training Presentation v2024.03
Cybersecurity Awareness Training Presentation v2024.03Cybersecurity Awareness Training Presentation v2024.03
Cybersecurity Awareness Training Presentation v2024.03
 
Japan IT Week 2024 Brochure by 47Billion (English)
Japan IT Week 2024 Brochure by 47Billion (English)Japan IT Week 2024 Brochure by 47Billion (English)
Japan IT Week 2024 Brochure by 47Billion (English)
 
Buy gmail accounts.pdf Buy Old Gmail Accounts
Buy gmail accounts.pdf Buy Old Gmail AccountsBuy gmail accounts.pdf Buy Old Gmail Accounts
Buy gmail accounts.pdf Buy Old Gmail Accounts
 
Chapter 9 PPT 4th edition.pdf internal audit
Chapter 9 PPT 4th edition.pdf internal auditChapter 9 PPT 4th edition.pdf internal audit
Chapter 9 PPT 4th edition.pdf internal audit
 
Darshan Hiranandani [News About Next CEO].pdf
Darshan Hiranandani [News About Next CEO].pdfDarshan Hiranandani [News About Next CEO].pdf
Darshan Hiranandani [News About Next CEO].pdf
 
Independent Call Girls Andheri Nightlaila 9967584737
Independent Call Girls Andheri Nightlaila 9967584737Independent Call Girls Andheri Nightlaila 9967584737
Independent Call Girls Andheri Nightlaila 9967584737
 
Flow Your Strategy at Flight Levels Day 2024
Flow Your Strategy at Flight Levels Day 2024Flow Your Strategy at Flight Levels Day 2024
Flow Your Strategy at Flight Levels Day 2024
 
Call Girls Contact Number Andheri 9920874524
Call Girls Contact Number Andheri 9920874524Call Girls Contact Number Andheri 9920874524
Call Girls Contact Number Andheri 9920874524
 
8447779800, Low rate Call girls in Kotla Mubarakpur Delhi NCR
8447779800, Low rate Call girls in Kotla Mubarakpur Delhi NCR8447779800, Low rate Call girls in Kotla Mubarakpur Delhi NCR
8447779800, Low rate Call girls in Kotla Mubarakpur Delhi NCR
 
Organizational Structure Running A Successful Business
Organizational Structure Running A Successful BusinessOrganizational Structure Running A Successful Business
Organizational Structure Running A Successful Business
 

Converting (X)HTML/CSS template to Drupal 7 Theme

  • 1. Converting (X)HTML/CSS template to DRUPAL 7 theme By: Adolfo G. Nasol – http://danreb.com http://cavhost.com
  • 2. Additional option for creating DRUPAL theme  As I said, this will give us another flavour on creating a Drupal 7 theme, Drupal THEMERS usually create themes using a base starter theme and modify to fit into their needs, with this, we are creating themes base on your existing (X)HTML structures and its corresponding CSS files. http://cavhost.com
  • 3. What Designer(s) and Noob think about Drupal Themeing?  Noob assume that Drupal theming is complicated and its overwhelming  They try to look at several Base starter themes and got confused (OMG, I've better stay with WordPress / Joomla)  Better create my own CMS huh! http://cavhost.com
  • 4. What should you do?  Never fear!, because its possible to create your own theme base on your designs and concepts and base on your existing (X)HTML and CSS structures and layout. http://cavhost.com
  • 5. What should we learn?  Step by step process for converting your (X)HTML/CSS template into Drupal 7 theme  Finds the location of Drupal’s default template files (.TPL files ) and modify as you need it.  Some examples and a demonstration http://cavhost.com
  • 6. Basic knowledge required  You need to know how to install and setup a Drupal site.  (X)HTML/CSS – of course!  Basic knowledge in PHP scripts  A little knowledge in JavaScript (jQuery)  Drupal Terminology (nodes, blocks, regions and etc...) http://cavhost.com
  • 7. Why not just use a Base Starter theme?  Hey, instructions for creating a Drupal theme usually tells us to start with an existing theme or base theme and customize it to fit to our needs. Do you have problem with that? Are you against it? - NOPE! http://cavhost.com
  • 8. Then you’d better explain!, What’s the problem?  Avoiding frustration(specially for noob). Existing themes and base theme often include options and features that you don't actually needs - lots of regions - bunch of CSS files that makes it work - So many features that make your site slow. This is fine if that's what you need but also result in very complex template files and bloated CSS. http://cavhost.com
  • 9. Then you’d better explain!, What’s the problem?  To help us learn how Drupal theming actually works and gain better understanding of the theming system. http://cavhost.com
  • 10. Drupal 7 themes http://cavhost.com
  • 11. Other valid reason?  Your client gives you an existing (x)html/css template and he wants you to use that for their drupal website. Using a base theme for this is a lot harder because you already have existing html structures and layout, CSS class and ID’s won’t match and your frustration begins. Instead of using a base theme, its better to convert that existing template directly into a DRUPAL 7 theme. http://cavhost.com
  • 12. Step by step process for Converting (X)HTML/CSS to Drupal 7 theme. Step 1 - Prepare the template Prepare your existing (X)HTML/CSS template, make sure all files are intact and working properly, test it in the browser if it is working fine and bug free. http://cavhost.com
  • 13. Step by step process for Converting (X)HTML/CSS to Drupal 7 theme. Adjust the following as a part of preparation process  Rename the logo as logo.png - Drupal looks for "logo.png" files inside a drupal themes and use it as default logo. If the logo is inside the images folder, copy that logo into the directory where the index.html file resides, they must be in the same level. http://cavhost.com
  • 14. Step by step process for Converting (X)HTML/CSS to Drupal 7 theme. (X)HTML/CSS layouts,  Analyze your existing each section of the template will need to be converted into DRUPAL block regions, tools such as firebug can help you or even an HTML editing software such as Adobe Dreamweaver.  Take note of the sections in the html template, we will use this sections as block region and we will need to define it in themename.info file. http://cavhost.com
  • 15. Step by step process for Converting (X)HTML/CSS to Drupal 7Create the folder for your theme Step 2 – theme. - Create a folder inside sites/all/themes/ directory, this will be the name of your Drupal theme, for example, if you created a folder named "mytheme" then your directory shall be "sites/all/themes/mytheme" http://cavhost.com
  • 16. Step by step process for Converting (X)HTML/CSS to Drupal 7Copy the files in themes folder Step 3 – theme. - Copy all the files in your (X)HTML/CSS templates into the directory you've just created "sites/all/themes/mytheme" , make sure to include all the HTML files, CSS, Images, JavaScript's and other assets and etc... http://cavhost.com
  • 17. Step by step process for Converting (X)HTML/CSS to Drupal –7 theme. Step 4 Create themename.info - Create "themename.info" file, name must be the same with your folder name, theme folder named "mytheme“ must have “mytheme.info” inside it. - Declare the following: name, description, core, engine, stylesheets, javascript’s, and regions. Visit http://drupal.org/node/171205 for information on .INFO file, look on bartik.info files for working examples, copy if necessary and update the information as needed. http://cavhost.com
  • 18. Step by step process for Converting (X)HTML/CSS to Drupal 7Create page.tpl.php Step 5 – theme.  Duplicate your main html file, usually "index.html“ or “index.htm” and rename the copy as page.tpl.php http://cavhost.com
  • 19. Step by step process for Converting (X)HTML/CSS to Drupal 7Copy all other TPL files you want to use Step 6 – theme. and overrides (optional)  Copy the template files you want to override and edit the mark-up (html.tpl.php, node.tpl.php, block.tpl.php), put this to your theme folder, this way you can edit the file without hacking the original in the core. Please check http://drupal.org/node/190815 for list of core templates. Also check core modules folder for available .TPL files. http://cavhost.com
  • 20. Step by step process for Converting (X)HTML/CSS to Drupal 7Edit page.tpl.php Step 7 – theme.  Open your page.tpl.php and edit, remove all tags starting from DOCTYPE up to opening <body> tag.  Scroll down to the bottom of the page.tpl.php and also remove the closing </body> body tag and the closing </html> html tag. http://cavhost.com
  • 21. Step by step process for Converting (X)HTML/CSS to Drupal 7Check and declare all the reference for Step 8 – theme. the CSS and JS file into .INFO file.  Take note of all references to CSS file and JS file in the header section of the (X)HTML file and make sure you declare this into your .INFO file.  Note that if your html template used jQuery library, you don’t need to include this to themename.info because Drupal already comes with jQuery library. http://cavhost.com
  • 22. Step by step process for Converting (X)HTML/CSS to Drupal 7 theme. regions Step 9– Insert your block  Start Inserting all your regions, any part of your page you want to be editable in the Drupal interface(via Blocks) need to be converted to a region. Code example: <?php if ($page['sidebar_second']): ?> <div id="sidebar-1" class="sidebar-1"> <?php print render($page['sidebar_second']); ?> </div> <!-- /#sidebar-1 --> <?php endif; ?> http://cavhost.com
  • 23. Step by step process for Converting (X)HTML/CSS to Drupal – Insert variables you want to use Step 10 7 theme.  Start Inserting all the necessary variables you want to use and you need in the proper spot where you want to show it on your page. Some of the most common variable in page.tpl.php $site_name $logo $title $main_menu $secondary_menu $breadcrumbs $tabs $messages Variables are inserted using the Render API, information can be found here -> http://drupal.org/node/930760 Example of printing tabs <?php print render($tabs); ?> http://cavhost.com
  • 24. Step by step process for Converting (X)HTML/CSS to Drupal 7 Adjust your CSS Step 11 – theme.  Adjust your CSS and override Drupal default style sheet as you need to fit your design into your Drupal site. Firebug can help you a lot with this to properly find the correct element class and id’s that you want to override. http://cavhost.com
  • 25. Step by step process for Converting (X)HTML/CSS to Drupal 7 theme. Step 12 – Test and Done!  And were Done! Note: Were done with the basic, its enough for you to be able to convert an existing html/css template to Drupal 7 theme. Advance theming use more .TPL files and requires you to create custom PHP code in template.php files, you need to learn how template hooks works and all the available pre-process functions. More information here: http://drupal.org/node/341628. http://cavhost.com
  • 26. Example of theme hook Adding external stylesheets ( template.php ) Code: <?php function mytheme_preprocess_html(&$variables) { drupal_add_css('http://fonts.googleapis.com/css?family=News+Cy cle', array('type' => 'external')); } ?> http://cavhost.com
  • 27. Theme Developer module Themer's usually use theme developer module that can be downloaded at http://drupal.org/project/devel_themer You can view template suggestion and existing variables value with the help of this module http://cavhost.com
  • 28. Helper PHP function If you don't want to install theme developer modules, you can use the following PHP function to inspect your page for variables and array values: Code: <pre> <?php var_dump($var); ?> </pre> Or with this one <pre> <?php $vars = get_defined_vars(); print_r($vars); ?> </pre> For more info, please visit: http://drupal.org/node/348916 http://cavhost.com
  • 29. Happy DRUPAL Theming!  Adolfo G. Nasol  Mobile: 09195951276  Blog: http://danreb.com  Website: http://cavhost.com  Email: adolfo@danreb.com More power, PHDUG – Philippine Drupal User Group! 2012 http://cavhost.com