SlideShare a Scribd company logo
1 of 132
Download to read offline
Grok Drupal
             Theming
                  Laura Scott
                       PINGV
                      @lauras
                     #grokd4d


Drupal Design Camp LA 2011
Laura Scott
Creative Director,
Drupal Architect
and Co-Founder
PINGV Creative



                "laura s"
                drupal.org/user/18973
                Drupal since 2004




                               @lauras
Grok Drupal Theming

Grok means to understand so thoroughly
that the observer becomes a part of the
observed ā€” to merge, blend, intermarry,
   lose identity in group experience.

  Robert A. Heinlein, Stranger in a Strange Land
<h1 id="title"> Grok Drupal Theming </h1>
<h1 id="title"> Grok Drupal Theming </h1>



    How Drupal displays content (templates)

             How to start theming

           Other things to consider
Assumptions
ā€¢   You know HTML/xhtml        ā€¢   You don't know PHP
                                   (but if you do, we won't
ā€¢   You know CSS 2.1               hold it against you)

ā€¢   You are at least getting   ā€¢   You understand some
    to know CSS 3 (or want         basic Drupal
    to)                            architecture concepts

ā€¢   Drupal theming confuses    ā€¢   You want to learn this
    or mystiļ¬es you
Some PHP required
ā€¢ Mainly to print pre-deļ¬ned variables ā€¦
  e.g., $title (for the page title).
ā€¢ You can do a lot in the "preprocess" and
  "process" functions.
ā€¢ You can avoid it if it totally scares the living
  daylights out of you. Just stick to copy and
  paste from '<?php' to '?>'.
HTML5 is coming!




 http://groups.drupal.org/html5
Theming for Drupal 7 is
 more powerful than
  previous versions
  ...but it's also a bit more complicated.
Anatomy of a Drupal "page"

    ā€¢   xhtml, CSS, bg images




    ā€¢   Content presented via
        templates




    ā€¢   JavaScript
The Drupal theme
 ā€¢ CSS ļ¬les
 ā€¢ Image ļ¬les
 ā€¢ Template ļ¬les
 ā€¢ JavaScript ļ¬les
 ā€¢ .info ļ¬le
 ā€¢ Preprocess and process   new!
ā€¢ CSS ļ¬les
ā€¢ Image ļ¬les
ā€¢ Template ļ¬les
ā€¢ JavaScript ļ¬les
ā€¢ Preprocess and process ļ¬les
ā€¢ .info ļ¬le
Which template?




                  It depends....
Which template?
                  page.tpl.php


                   ā€¢   logo
                   ā€¢   main title
                   ā€¢   regions
                   ā€¢   footer

                       and

                   ā€¢ other templates
Which template?   html.tpl.php
                                          new!
                  page.tpl.php




                       ā€¢ !DOCTYPE
                       ā€¢ <head> stuff
                       ā€¢ Drupal calls for CSS and JavaScript*
                       ā€¢ <body> container
Which template?   html.tpl.php
                  page.tpl.php
                  node.tpl.php
                  ā€¢ node title
                  ā€¢ node author
                  ā€¢ post date
                  ā€¢ node content
                  ā€¢ node taxonomy terms
                  ā€¢ node links
Which template?   html.tpl.php
                  page.tpl.php
                  node.tpl.php




                  comment-wrapper.tpl.php
                  ā€¢ Comment area title?
                  ā€¢ Comment templates
Which template?   html.tpl.php
                  page.tpl.php
                  node.tpl.php




                  comment-wrapper.tpl.php
                   comment.tpl.php
                   ā€¢ Comment title?
                   ā€¢ Comment author
                   ā€¢ Comment content
                   ā€¢ Comment links
Which template?         html.tpl.php
                        page.tpl.php
                        node.tpl.php              block.tpl.php
                                                  ā€¢ Block title
                                                  ā€¢ Block content




                        comment-wrapper.tpl.php
                         comment.tpl.php


*We'll come back to
this, because there's
      one more very
    important thing.
Every module's output
also has a template ļ¬le.
         (In theory.)
42 *.tpl.php ļ¬les in D7's /modules folder.

  Each can be copied into your theme
         and used to override.
The Views UI gives you template code
      to override Views output.
One theme might
 have dozens of
 template ļ¬les.
There are only
  a few basics.


  (It's not rocket science.)
What's inside a
 template?
html.tpl.php
html.tpl.php
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN"
   "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php
 print $language->language; ?>" version="XHTML+RDFa 1.0"
 dir="<?php print $language->dir; ?>"
   <?php print $rdf_namespaces; ?>>
html.tpl.php
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN"
   "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php
 print $language->language; ?>" version="XHTML+RDFa 1.0"
 dir="<?php print $language->dir; ?>"
   <?php print $rdf_namespaces; ?>>
 <head profile="<?php print $grddl_profile; ?>">
   <?php print $head; ?>
   <title><?php print $head_title; ?></title>
   <?php print $styles; ?>
   <?php print $scripts; ?>
 </head>
html.tpl.php
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN"
   "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php
 print $language->language; ?>" version="XHTML+RDFa 1.0"
 dir="<?php print $language->dir; ?>"
   <?php print $rdf_namespaces; ?>>
 <head profile="<?php print $grddl_profile; ?>">
   <?php print $head; ?>
   <title><?php print $head_title; ?></title>
   <?php print $styles; ?>
   <?php print $scripts; ?>
 </head>
 <body class="<?php print $classes; ?>" <?php print
 $attributes;?>>
   <div id="skip-link">
     <a href="#main-content" class="element-invisible
 element-focusable"><?php print t('Skip to main
 content'); ?></a>
   </div>
   <?php print $page_top; ?>
   <?php print $page; ?>
   <?php print $page_bottom; ?>
 </body>
 </html>
<body class="<?php print $classes; ?>" <?php print
$attributes;?>>
  <div id="skip-link">
    <a href="#main-content" class="element-invisible
element-focusable"><?php print t('Skip to main
content'); ?></a>
  </div>
  <?php print $page_top; ?>
  <?php print $page; ?>
  <?php print $page_bottom; ?>
</body>
</html>
page.tpl.php
page.tpl.php
  <div id="page-wrapper"><div id="page">

    <div id="header"><div class="section clearfix">

      <?php if ($logo): ?>
        <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home" id="logo">
                                                                                                                                   logo
          <img src="<?php print $logo; ?>" alt="<?php print t('Home'); ?>" />



                                                                                                                                site name
        </a>
      <?php endif; ?>

      <?php if ($site_name || $site_slogan): ?>
        <div id="name-and-slogan">
          <?php if ($site_name): ?>
            <?php if ($title): ?>


                                                                                                                                site slogan
              <div id="site-name"><strong>
                <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home"><span><?php print
$site_name; ?></span></a>
              </strong></div>
            <?php else: /* Use h1 when the content title is empty */ ?>
              <h1 id="site-name">



                                                                                                                               main menu
                <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home"><span><?php print
$site_name; ?></span></a>
              </h1>
            <?php endif; ?>
          <?php endif; ?>

          <?php if ($site_slogan): ?>


                                                                                                                               breadcrumb
            <div id="site-slogan"><?php print $site_slogan; ?></div>
          <?php endif; ?>
        </div> <!-- /#name-and-slogan -->
      <?php endif; ?>

      <?php print render($page['header']); ?>



                                                                                                                                messages
    </div></div> <!-- /.section, /#header -->

    <?php if ($main_menu): ?>
      <div id="navigation"><div class="section">
        <?php print theme('links__system_main_menu', array('links' => $main_menu, 'attributes' => array('id' => 'main-menu',
'class' => array('links', 'clearfix')), 'heading' => t('Main menu'))); ?>



                                                                                                                                 highight
      </div></div> <!-- /.section, /#navigation -->
    <?php endif; ?>

    <?php if ($breadcrumb): ?>
      <div id="breadcrumb"><?php print $breadcrumb; ?></div>
    <?php endif; ?>



                                                                                                                                <h1> title
    <?php print $messages; ?>

    <div id="main-wrapper"><div id="main" class="clearfix">

      <div id="content" class="column"><div class="section">



                                                                                                                                   tabs
        <?php if ($page['highlight']): ?><div id="highlight"><?php print render($page['highlight']); ?></div><?php endif; ?>
        <a id="main-content"></a>
        <?php print render($title_prefix); ?>
        <?php if ($title): ?><h1 class="title" id="page-title"><?php print $title; ?></h1><?php endif; ?>
        <?php print render($title_suffix); ?>
        <?php if ($tabs): ?><div class="tabs"><?php print render($tabs); ?></div><?php endif; ?>


                                                                                                                                   help
        <?php print render($page['help']); ?>
        <?php if ($action_links): ?><ul class="action-links"><?php print render($action_links); ?></ul><?php endif; ?>
        <?php print render($page['content']); ?>
        <?php print $feed_icons; ?>
      </div></div> <!-- /.section, /#content -->



                                                                                                                                 content
      <?php if ($page['sidebar_first']): ?>
        <div id="sidebar-first" class="column sidebar"><div class="section">
          <?php print render($page['sidebar_first']); ?>
        </div></div> <!-- /.section, /#sidebar-first -->
      <?php endif; ?>

      <?php if ($page['sidebar_second']): ?>
        <div id="sidebar-second" class="column sidebar"><div class="section">
          <?php print render($page['sidebar_second']); ?>
        </div></div> <!-- /.section, /#sidebar-second -->
                                                                                                                               feed icons
      <?php endif; ?>

    </div></div> <!-- /#main, /#main-wrapper -->

    <div id="footer"><div class="section">
      <?php print theme('links__system_secondary_menu', array('links' => $secondary_menu, 'attributes' => array('id' =>
                                                                                                                                sidebars
                                                                                                                                  footer
'secondary-menu', 'class' => array('links', 'clearfix')), 'heading' => t('Secondary menu'))); ?>
      <?php print render($page['footer']); ?>
    </div></div> <!-- /.section, /#footer -->

  </div></div> <!-- /#page, /#page-wrapper -->
The Semantic Page
ā€¢ Logo/branding/site name
ā€¢ [main nav]*
ā€¢ <h1> Title (of article, view, blog post, etc.)
ā€¢ Main content
ā€¢ Then secondary content (aka "sidebars"),
  footer
             * and that's debated
<a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home"><span><?
  php print $site_name; ?></span></a>

page.tpl.php
                </h1>
              <?php endif; ?>
            <?php endif; ?>

            <?php if ($site_slogan): ?>
              <div id="site-slogan"><?php print $site_slogan; ?></div>
            <?php endif; ?>
          </div> <!-- /#name-and-slogan -->
        <?php endif; ?>
        <?php print render($page['header']); ?>

      </div></div> <!-- /.section, /#header -->
      <?php if ($main_menu): ?>
        <div id="navigation"><div class="section">
          <?php print theme('links__system_main_menu', array('links' => $main_menu, 'attributes' => array('id'
  => 'main-menu', 'class' => array('links', 'clearfix')), 'heading' => t('Main menu'))); ?>
        </div></div> <!-- /.section, /#navigation -->
      <?php endif; ?>
      <?php if ($breadcrumb): ?>
        <div id="breadcrumb"><?php print $breadcrumb; ?></div>
      <?php endif; ?>
      <?php print $messages; ?>
      <div id="main-wrapper"><div id="main" class="clearfix">
        <div id="content" class="column"><div class="section">
          <?php if ($page['highlight']): ?><div id="highlight"><?php print render($page['highlight']); ?></
  div><?php endif; ?>
          <a id="main-content"></a>
          <?php print render($title_prefix); ?>
          <?php if ($title): ?><h1 class="title" id="page-title"><?php print $title; ?></h1><?php endif; ?>
          <?php print render($title_suffix); ?>
          <?php if ($tabs): ?><div class="tabs"><?php print render($tabs); ?></div><?php endif; ?>
          <?php print render($page['help']); ?>
          <?php if ($action_links): ?><ul class="action-links"><?php print render($action_links); ?></ul><?php
  endif; ?>
          <?php print render($page['content']); ?>
          <?php print $feed_icons; ?>
        </div></div> <!-- /.section, /#content -->
        <?php if ($page['sidebar_first']): ?>
          <div id="sidebar-first" class="column sidebar"><div class="section">
            <?php print render($page['sidebar_first']); ?>
          </div></div> <!-- /.section, /#sidebar-first -->
        <?php endif; ?>
        <?php if ($page['sidebar_second']): ?>
          <div id="sidebar-second" class="column sidebar"><div class="section">
            <?php print render($page['sidebar_second']); ?>
          </div></div> <!-- /.section, /#sidebar-second -->
        <?php endif; ?>
     </div></div> <!-- /#main, /#main-wrapper -->
     <div id="footer"><div class="section">
           <?php print theme('links__system_secondary_menu', array('links' => $secondary_menu, 'attributes' =>
     array('id' => 'secondary-menu', 'class' => array('links', 'clearfix')), 'heading' => t('Secondary
     menu'))); ?>
           <?php print render($page['footer']); ?>
         </div></div> <!-- /.section, /#footer -->
<a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home"><span><?
  php print $site_name; ?></span></a>

page.tpl.php
                </h1>
              <?php endif; ?>
            <?php endif; ?>

            <?php if ($site_slogan): ?>
              <div id="site-slogan"><?php print $site_slogan; ?></div>
            <?php endif; ?>
          </div> <!-- /#name-and-slogan -->
        <?php endif; ?>
        <?php print render($page['header']); ?>

      </div></div> <!-- /.section, /#header -->
      <?php print $messages; ?>
      <div id="main-wrapper"><div id="main" class="clearfix">
        <div id="content" class="column"><div class="section">
          <?php if ($page['highlight']): ?><div id="highlight"><?php print render($page['highlight']); ?></
  div><?php endif; ?>
          <a id="main-content"></a>
          <?php print render($title_prefix); ?>
          <?php if ($title): ?><h1 class="title" id="page-title"><?php print $title; ?></h1><?php endif; ?>
          <?php print render($title_suffix); ?>
          <?php if ($tabs): ?><div class="tabs"><?php print render($tabs); ?></div><?php endif; ?>
          <?php print render($page['help']); ?>
          <?php if ($action_links): ?><ul class="action-links"><?php print render($action_links); ?></ul><?php
  endif; ?>
          <?php print render($page['content']); ?>
          <?php print $feed_icons; ?>
        </div></div> <!-- /.section, /#content -->
        <?php if ($page['sidebar_first']): ?>
          <div id="sidebar-first" class="column sidebar"><div class="section">
            <?php print render($page['sidebar_first']); ?>
          </div></div> <!-- /.section, /#sidebar-first -->
        <?php endif; ?>
        <?php if ($page['sidebar_second']): ?>
          <div id="sidebar-second" class="column sidebar"><div class="section">
            <?php print render($page['sidebar_second']); ?>
          </div></div> <!-- /.section, /#sidebar-second -->
        <?php endif; ?>
      </div></div> <!-- /#main, /#main-wrapper -->
      <?php if ($main_menu): ?>
        <div id="navigation"><div class="section">
          <?php print theme('links__system_main_menu', array('links' => $main_menu, 'attributes' => array('id'
  => 'main-menu', 'class' => array('links', 'clearfix')), 'heading' => t('Main menu'))); ?>
        </div></div> <!-- /.section, /#navigation -->
      <?php endif; ?>
      <?php if ($breadcrumb): ?>
        <div id="breadcrumb"><?php print $breadcrumb; ?></div>
      <?php endif; ?>
     <div id="footer"><div class="section">
           <?php print theme('links__system_secondary_menu', array('links' => $secondary_menu, 'attributes' =>
     array('id' => 'secondary-menu', 'class' => array('links', 'clearfix')), 'heading' => t('Secondary
     menu'))); ?>
           <?php print render($page['footer']); ?>
         </div></div> <!-- /.section, /#footer -->
node.tpl.php
node.tpl.php
   <div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?>
   clearfix"<?php print $attributes; ?>>
     <?php print $user_picture; ?>
     <?php print render($title_prefix); ?>
     <?php if (!$page): ?>
       <h2<?php print $title_attributes; ?>><a href="<?php print $node_url; ?
   >"><?php print $title; ?></a></h2>
     <?php endif; ?>
     <?php print render($title_suffix); ?>
     <?php if ($display_submitted): ?>
       <div class="submitted">
         <?php
            print t('Submitted by !username on !datetime',
              array('!username' => $name, '!datetime' => $date));
         ?>
       </div>
     <?php endif; ?>
     <div class="content"<?php print $content_attributes; ?>>
       <?php
          // We hide the comments and links now so that we can render them
   later.
          hide($content['comments']);
          hide($content['links']);
          print render($content);
       ?>
     </div>
     <?php print render($content['links']); ?>
     <?php print render($content['comments']); ?>
   </div>
node.tpl.php
   <div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?>
   clearfix"<?php print $attributes; ?>>
     <?php print $user_picture; ?>
     <?php print render($title_prefix); ?>
     <?php if (!$page): ?>
       <h2<?php print $title_attributes; ?>><a href="<?php print $node_url; ?
   >"><?php print $title; ?></a></h2>
     <?php endif; ?>
     <?php print render($title_suffix); ?>
     <?php if ($display_submitted): ?>
       <div class="submitted">
         <?php
            print t('Submitted by !username on !datetime',
              array('!username' => $name, '!datetime' => $date));
         ?>
       </div>
     <?php endif; ?>
     <div class="content"<?php print $content_attributes; ?>>
       <?php
          // We hide the comments and links now so that we can render them
   later.
          hide($content['comments']);
          hide($content['links']);
          print render($content);
       ?>
     </div>
     <?php print render($content['links']); ?>
     <?php print render($content['comments']); ?>
                                                        new!
   </div>
comment-wrapper.tpl.php
comment-wrapper.tpl.php

<div id="comments" class="<?php print $classes; ?>"<?php
print $attributes; ?>>
  <?php if ($content['comments'] && $node->type !=
'forum'): ?>
    <?php print render($title_prefix); ?>
    <h2 class="title"><?php print t('Comments'); ?></h2>
    <?php print render($title_suffix); ?>
  <?php endif; ?>

  <?php print render($content['comments']); ?>

  <?php if ($content['comment_form']): ?>
    <h2 class="title comment-form"><?php print t('Add
new comment'); ?></h2>
    <?php print render($content['comment_form']); ?>
  <?php endif; ?>
</div>
comment.tpl.php
comment.tpl.php

<div class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>
  <?php print $picture ?>

  <?php if ($new): ?>
    <span class="new"><?php print $new ?></span>
  <?php endif; ?>

  <?php print render($title_prefix); ?>
  <h3<?php print $title_attributes; ?>><?php print $title ?></h3>
  <?php print render($title_suffix); ?>

  <div class="submitted">
    <?php print $permalink; ?>
    <?php print $submitted; ?>
  </div>

  <div class="content"<?php print $content_attributes; ?>>
    <?php
       // We hide the comments and links now so that we can render them later.
       hide($content['links']);
       print render($content);
    ?>
    <?php if ($signature): ?>
    <div class="user-signature clearfix">
       <?php print $signature ?>
    </div>
    <?php endif; ?>
  </div>

  <?php print render($content['links']) ?>
</div>
block.tpl.php
block.tpl.php

<div id="<?php print $block_html_id; ?>" class="<?php
print $classes; ?>"<?php print $attributes; ?>>

  <?php print render($title_prefix); ?>
<?php if ($block->subject): ?>
  <h2<?php print $title_attributes; ?>><?php print
$block->subject ?></h2>
<?php endif;?>
  <?php print render($title_suffix); ?>

     <div class="content"<?php print $content_attributes; ?
>>
    <?php print $content ?>
  </div>
</div>
block.tpl.php

<div id="<?php print $block_html_id; ?>" class="<?php
print $classes; ?>"<?php print $attributes; ?>>

  <?php print render($title_prefix); ?>
<?php if ($block->subject): ?>
  <h2<?php print $title_attributes; ?>><?php print
$block->subject ?></h2>
<?php endif;?>
  <?php print render($title_suffix); ?>

     <div class="content"<?php print $content_attributes; ?
>>
    <?php print $content ?>
  </div>
</div>
polls
node.tpl.php        node.tpl.php


poll-vote.tpl.php   poll-results.tpl.php
                    poll-bar.tpl.php
block.tpl.php       block.tpl.php


poll-vote.tpl.php   poll-results--block.tpl.php
                     poll-bar--block.tpl.php
Fields are in core   It's nice to
                     have a home.
ļ¬eld.tpl.php
ļ¬eld.tpl.php

   <div class="<?php print $classes; ?> clearfix"<?php
   print $attributes; ?>>
     <?php if (!$label_hidden) : ?>
       <div class="field-label"<?php print
   $title_attributes; ?>><?php print $label ?>:&nbsp;</div>
     <?php endif; ?>
     <div class="field-items"<?php print
   $content_attributes; ?>>
       <?php foreach ($items as $delta => $item) : ?>
          <div class="field-item <?php print $delta % 2 ?
   'odd' : 'even'; ?>"<?php print $item_attributes
   [$delta]; ?>><?php print render($item); ?></div>
       <?php endforeach; ?>
     </div>
   </div>
html.tpl.php
page.tpl.php
node.tpl.php              block.tpl.php




comment-wrapper.tpl.php
 comment.tpl.php
html.tpl.php
page.tpl.php
region.tpl.php

region.tpl.php            region.tpl.php

node.tpl.php              block.tpl.php


comment-wrapper.tpl.php
 comment.tpl.php




region.tpl.php
new!




region.tpl.php
region.tpl.php




          <?php if ($content): ?>
            <div class="<?php print $classes; ?>">
              <?php print $content; ?>
            </div>
          <?php endif; ?>
So if all regions use the same template,
how does Drupal know which region?
<?php print render($page['header']); ?>
<?php print render($page['header']); ?>

     <?php print render($page['help']); ?>

  <?php print render($page['highlight']); ?>

   <?php print render($page['content']); ?>

<?php print render($page['sidebar_first']); ?>

<?php print render($page['sidebar_second']); ?>

    <?php print render($page['footer']); ?>
All regions in your theme must be declared,
        or else you get these defaults.
Where the heck are all these templates?
example.com/modules
Preprocess


scary
  doesn't have to be
Everything is an array
        pretty much
So how to go about
 creating a theme?
Create a theme from scratch,
     making everything

               ā€¢   theme .info ļ¬le

               ā€¢   page.tpl.php

               ā€¢   *.tpl.php ļ¬les as
                   needed to override
                   core

               ā€¢   template.php for your
                   preprocess and
                   process

               ā€¢   background images
or make a baby!
Sub-themes
inherit
everything from
parent theme,




                  except what is overridden.
Inheritance

html.tpl.php




page.tpl.php




node.tpl.php




block.tpl.php
Inheritance

html.tpl.php




page.tpl.php          page.tpl.php




node.tpl.php          node.tpl.php




block.tpl.php
Inheritance

html.tpl.php          html.tpl.php




page.tpl.php          page.tpl.php




node.tpl.php          node.tpl.php




block.tpl.php
Inheritance


base.css          base.css



type.css          type.css



forms.css
Many good base themes
Copy in the base theme


example.com/themes/

example.com/sites/all/themes/basetheme
Create your child theme


example.com/themes/

example.com/sites/all/themes/yourtheme
sites

        all

              themes

                   yourtheme


                               yourtheme.info

                               template.php

                               license.txt

                               css

                               images

                               templates
yourtheme.info
yourtheme.info
    name = yourtheme
    description = This is where you describe your theme in words.
    version = 1.0

    ; Requirements
    base theme = ninesixty
    core = 7.x
    engine = phptemplate

    ; Stylesheets
    stylesheets[all][] = styles.css
    stylesheets[screen][] = styles/base.css
    stylesheets[screen][] = styles/layout.css
    stylesheets[screen][] = styles/colors.css
    stylesheets[screen][] = styles/forms.css
    stylesheets[print][] = styles/print.css

    ; Regions
    regions[header] = Header
    regions[help] = Help
    regions[highlight] = Highlight
    regions[content] = Content
    regions[page_top] = Page top
    regions[page_bottom] = Page bottom
    regions[indicators] = Indicators
    regions_hidden[] = indicators

    ; Scripts
    scripts[] = script.js
    scripts[] = scripts/twitter.js
yourtheme.info
    name = yourtheme
    description = This is where you describe your theme in words.
    version = 1.0

    ; Requirements
    base theme = ninesixty
    core = 7.x
    engine = phptemplate

    ; Stylesheets
    stylesheets[all][] = styles.css
    stylesheets[screen][] = styles/base.css
    stylesheets[screen][] = styles/layout.css
    stylesheets[screen][] = styles/colors.css
    stylesheets[screen][] = styles/forms.css
    stylesheets[print][] = styles/print.css

    ; Regions
    regions[header] = Header
    regions[help] = Help
    regions[highlight] = Highlight
    regions[content] = Content
    regions[page_top] = Page top
    regions[page_bottom] = Page bottom
    regions[indicators] = Indicators
    regions_hidden[] = indicators

    ; Scripts
    scripts[] = script.js
    scripts[] = scripts/twitter.js
In Drupal 7,
  if you're creating a theme from
  scratch, you must now declare
style.css and script.js in your .info
 ļ¬le, or they will not be included.
yourtheme.info
    name = yourtheme
    description = This is where you describe your theme in words.
    version = 1.0

    ; Requirements
    base theme = ninesixty
    core = 7.x
    engine = phptemplate

    ; Stylesheets
    stylesheets[all][] = styles.css
    stylesheets[screen][] = styles/base.css
    stylesheets[screen][] = styles/layout.css
    stylesheets[screen][] = styles/colors.css
    stylesheets[screen][] = styles/forms.css
    stylesheets[print][] = styles/print.css

    ; Regions
    regions[header] = Header
    regions[help] = Help
    regions[highlight] = Highlight
    regions[content] = Content
    regions[page_top] = Page top
    regions[page_bottom] = Page bottom
    regions[indicators] = Indicators
    regions_hidden[] = indicators

    ; Scripts
    scripts[] = script.js
    scripts[] = scripts/twitter.js
Template Suggestions

ā€¢ Create a base template of that type
ā€¢ Create variations on it to apply in certain
  circumstances
ā€¢ No coding necessary
                http://drupal.org/node/190815
Template Suggestions
            by content type

             node.tpl.php

blog                node--blog.tpl.php
event               node--event.tpl.php
classiļ¬ed           node--classiļ¬ed.tpl.php
product             node--product.tpl.php
Template Suggestions
            by content type
                                  new!
             node.tpl.php

blog                node--blog.tpl.php
event               node--event.tpl.php
classiļ¬ed           node--classiļ¬ed.tpl.php
product             node--product.tpl.php
Delimiters use two: '--'
       Words still use one: '-'



event-meeting    node--event-meeting.tpl.php

event-party      node--event-party.tpl.php
new!

And no longer need
    node.tpl.php
   in your theme
  in order to use
node--event.tpl.php.
new!

Wildcards in tpl names
    page--user--42.tpl.php

    page--user--%.tpl.php

   override all user displays
    without affecting /user
new!



.clear-block
   is now
  .clearļ¬x
Alter Hooks


hook_page_alter()
hook_form_alter()
hook_css_alter()
hook_js_alter()
Conditional CSS
  still needs trickery
//IE6 overrides
drupal_add_css(
   path_to_theme() . '/fix-ie.css', array(
     'group' => CSS_THEME,
     'browsers' => array(
        'IE' => 'lt IE 7',
        '!IE' => FALSE
     ),
     'preprocess' => FALSE
   )
);
new!



    Classes and Attributes
      are now standard
and predeļ¬ned without futzing
(although you can still futz if you want).
<div id="example" class="<?php print $classes; ?>
clearļ¬x"<?php print $attributes; ?>>


...


</div>
node.tpl.php

<div id="node-<?php print $node->nid; ?>"
class="<?php print $classes; ?> clearļ¬x"<?php print
$attributes; ?>>


...


</div>
Attributes
                              new!




ā€¢ $attributes
ā€¢ $title_attributes for titles
ā€¢ $content_attributes for content
<div id="example" class="<?php print
$classes; ?>"<?php print $attributes; ?>>

  <h2<?php print $title_attributes; ?>>...</h2>

  <div class="content"<?php print
$content_attributes; ?>>
...

  </div>

</div>
Be nice to
   robots!




photo: Don Solo
ļ¬‚ickr.com/photos/donsolo/3950364004/
RDFa
ā€¢ Robot food
ā€¢ An entire language
     to learn
ā€¢ Theming just got a
     lot more technical


photo: Don Solo
ļ¬‚ickr.com/photos/donsolo/3950364004/
Image: Davie60r
ļ¬‚ickr.com/photos/davie60r/3274499595/
Robots just want to
Hand over   I'm hungry!
your RDF!                 understand your site.


                               Hmmmmmā€¦.
                                 dataā€¦..




                             Image: bbaltimore
                             ļ¬‚ickr.com/photos/bbaltimore/6778028/
Dance with
      them!




                                       It's easy!

Image: Eric__I_E
ļ¬‚ickr.com/photos/deadling/256390679/
html.tpl.php


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa
1.0//EN"
  "http://www.w3.org/MarkUp/DTD/xhtml-
rdfa-1.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xml:lang="<?php print $language->language; ?>"
version="XHTML+RDFa 1.0" dir="<?php print
$language->dir; ?>"
  <?php print $rdf_namespaces; ?>>
html.tpl.php


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa
1.0//EN"
  "http://www.w3.org/MarkUp/DTD/xhtml-
rdfa-1.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xml:lang="<?php print $language->language; ?>"
version="XHTML+RDFa 1.0" dir="<?php print
$language->dir; ?>"
  <?php print $rdf_namespaces; ?>>
html.tpl.php


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa
1.0//EN"
  "http://www.w3.org/MarkUp/DTD/xhtml-
rdfa-1.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xml:lang="<?php print $language->language; ?>"
version="XHTML+RDFa 1.0" dir="<?php print
$language->dir; ?>"
  <?php print $rdf_namespaces; ?>>
html.tpl.php


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa
1.0//EN"
  "http://www.w3.org/MarkUp/DTD/xhtml-
rdfa-1.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xml:lang="<?php print $language->language; ?>"
version="XHTML+RDFa 1.0" dir="<?php print
$language->dir; ?>"
  <?php print $rdf_namespaces; ?>>
html.tpl.php


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa
1.0//EN"
  "http://www.w3.org/MarkUp/DTD/xhtml-
rdfa-1.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xml:lang="<?php print $language->language; ?>"
version="XHTML+RDFa 1.0" dir="<?php print
$language->dir; ?>"
  <?php print $rdf_namespaces; ?>>
html.tpl.php


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa
1.0//EN"
  "http://www.w3.org/MarkUp/DTD/xhtml-
rdfa-1.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xml:lang="<?php print $language->language; ?>"
version="XHTML+RDFa 1.0" dir="<?php print
$language->dir; ?>"
  <?php print $rdf_namespaces; ?>>

<head profile="<?php print $grddl_profile; ?
>">
Do I really need to do
RDFa to use Drupal?

   No, you can just ignore
  it, and work on the same
    level as other systems.
  But you'll be missing out.



Photo: FlySi
ļ¬‚ickr.com/photos/ļ¬‚ysi/183272970/
Attributes

ā€¢ $attributes
ā€¢ $title_attributes for titles
ā€¢ $content_attributes for content
Basics to Remember
ā€¢ Create your theme in
  sites/all/themes/yourtheme
ā€¢ Copy templates into your theme to make
  overrides
ā€¢ Use template suggestions to break out
  distinct structures and stylings
ā€¢ Use base theme to get a jump on things
ā€¢ Let Drupal do what it does best
Points of Modiļ¬cation

  ā€¢ CSS
  ā€¢ xhtml in the template that applies
  ā€¢ preprocess
  ā€¢ module
Resources
ā€¢ Drupal 6 Ā» Drupal 7 theming
  changes
  drupal.org/update/theme/6/7
ā€¢ Template suggestions
  drupal.org/node/190815*

ā€¢ RDFa
  buytaert.net/semantic-web-
  and-drupal-video
          * Drupal 6
Get Drush!


 Yeah yeah yeah, I know, you don't like command line, but this will really really and for true help you save time
developing so that you can spend more time designing and theming, and isn't that what you'd rather do anyway?
                                          Video to make it easy:

                               http://is.gd/             aZe33
@lauras
rarepattern.com/contact




        Ā©2010 Laura Scott
Questions?




         @lauras

More Related Content

What's hot

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
Ā 
Creating Responsive Drupal Sites with Zen Grids and the Zen 5 Theme
Creating Responsive Drupal Sites with Zen Grids and the Zen 5 ThemeCreating Responsive Drupal Sites with Zen Grids and the Zen 5 Theme
Creating Responsive Drupal Sites with Zen Grids and the Zen 5 ThemeAcquia
Ā 
Drupal distributions - how to build them
Drupal distributions - how to build themDrupal distributions - how to build them
Drupal distributions - how to build themDick Olsson
Ā 
Using Core Themes in Drupal 8
Using Core Themes in Drupal 8Using Core Themes in Drupal 8
Using Core Themes in Drupal 8Suzanne Dergacheva
Ā 
Theme Kickstart
Theme KickstartTheme Kickstart
Theme KickstartPeter
Ā 
The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017Amanda Giles
Ā 
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
Ā 
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
Ā 
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
Ā 
WordPress theme development from scratch : ICT MeetUp 2013 Nepal
WordPress theme development from scratch : ICT MeetUp 2013 NepalWordPress theme development from scratch : ICT MeetUp 2013 Nepal
WordPress theme development from scratch : ICT MeetUp 2013 NepalChandra Prakash Thapa
Ā 
CSS pattern libraries
CSS pattern librariesCSS pattern libraries
CSS pattern librariesRuss Weakley
Ā 
From PSD to WordPress Theme: Bringing designs to life
From PSD to WordPress Theme: Bringing designs to lifeFrom PSD to WordPress Theme: Bringing designs to life
From PSD to WordPress Theme: Bringing designs to lifeDerek Christensen
Ā 
WordPress Theme Development for Designers
WordPress Theme Development for DesignersWordPress Theme Development for Designers
WordPress Theme Development for Designerselliotjaystocks
Ā 
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
Ā 
Custom WordPress theme development
Custom WordPress theme developmentCustom WordPress theme development
Custom WordPress theme developmentTammy Hart
Ā 
PSD to a Drupal Theme (using a base theme)
PSD to a Drupal Theme (using a base theme)PSD to a Drupal Theme (using a base theme)
PSD to a Drupal Theme (using a base theme)kuydigital
Ā 
Introduction to WordPress Theme Development
Introduction to WordPress Theme DevelopmentIntroduction to WordPress Theme Development
Introduction to WordPress Theme DevelopmentSitdhibong Laokok
Ā 

What's hot (20)

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
Ā 
Creating Responsive Drupal Sites with Zen Grids and the Zen 5 Theme
Creating Responsive Drupal Sites with Zen Grids and the Zen 5 ThemeCreating Responsive Drupal Sites with Zen Grids and the Zen 5 Theme
Creating Responsive Drupal Sites with Zen Grids and the Zen 5 Theme
Ā 
Drupal distributions - how to build them
Drupal distributions - how to build themDrupal distributions - how to build them
Drupal distributions - how to build them
Ā 
Using Core Themes in Drupal 8
Using Core Themes in Drupal 8Using Core Themes in Drupal 8
Using Core Themes in Drupal 8
Ā 
Intro to HTML 5 / CSS 3
Intro to HTML 5 / CSS 3Intro to HTML 5 / CSS 3
Intro to HTML 5 / CSS 3
Ā 
Theme Kickstart
Theme KickstartTheme Kickstart
Theme Kickstart
Ā 
The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017
Ā 
Arizona WP - Building a WordPress Theme
Arizona WP - Building a WordPress ThemeArizona WP - Building a WordPress Theme
Arizona WP - Building a WordPress Theme
Ā 
WordPress Theme Development: Part 2
WordPress Theme Development: Part 2WordPress Theme Development: Part 2
WordPress Theme Development: Part 2
Ā 
Design to Theme @ CMSExpo
Design to Theme @ CMSExpoDesign to Theme @ CMSExpo
Design to Theme @ CMSExpo
Ā 
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
Ā 
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
Ā 
WordPress theme development from scratch : ICT MeetUp 2013 Nepal
WordPress theme development from scratch : ICT MeetUp 2013 NepalWordPress theme development from scratch : ICT MeetUp 2013 Nepal
WordPress theme development from scratch : ICT MeetUp 2013 Nepal
Ā 
CSS pattern libraries
CSS pattern librariesCSS pattern libraries
CSS pattern libraries
Ā 
From PSD to WordPress Theme: Bringing designs to life
From PSD to WordPress Theme: Bringing designs to lifeFrom PSD to WordPress Theme: Bringing designs to life
From PSD to WordPress Theme: Bringing designs to life
Ā 
WordPress Theme Development for Designers
WordPress Theme Development for DesignersWordPress Theme Development for Designers
WordPress Theme Development for Designers
Ā 
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
Ā 
Custom WordPress theme development
Custom WordPress theme developmentCustom WordPress theme development
Custom WordPress theme development
Ā 
PSD to a Drupal Theme (using a base theme)
PSD to a Drupal Theme (using a base theme)PSD to a Drupal Theme (using a base theme)
PSD to a Drupal Theme (using a base theme)
Ā 
Introduction to WordPress Theme Development
Introduction to WordPress Theme DevelopmentIntroduction to WordPress Theme Development
Introduction to WordPress Theme Development
Ā 

Similar to Grok Drupal (7) Theming - 2011 Feb update

PSD to WordPress
PSD to WordPressPSD to WordPress
PSD to WordPressNile Flores
Ā 
D7 theming what's new - London
D7 theming what's new - LondonD7 theming what's new - London
D7 theming what's new - LondonMarek Sotak
Ā 
WordPress Theme Workshop: Part 4
WordPress Theme Workshop: Part 4WordPress Theme Workshop: Part 4
WordPress Theme Workshop: Part 4David Bisset
Ā 
How to create a basic template
How to create a basic templateHow to create a basic template
How to create a basic templatevathur
Ā 
Drupal Themes
Drupal ThemesDrupal Themes
Drupal Themesakosh
Ā 
The Way to Theme Enlightenment
The Way to Theme EnlightenmentThe Way to Theme Enlightenment
The Way to Theme EnlightenmentAmanda Giles
Ā 
Word press templates
Word press templatesWord press templates
Word press templatesDan Phiffer
Ā 
Drupal theming
Drupal themingDrupal theming
Drupal themingPhilip Norton
Ā 
WordPress Theme Workshop: Part 3
WordPress Theme Workshop: Part 3WordPress Theme Workshop: Part 3
WordPress Theme Workshop: Part 3David Bisset
Ā 
Joomla! Day Chicago 2011 - Templating the right way - Jonathan Shroyer
Joomla! Day Chicago 2011 - Templating the right way - Jonathan ShroyerJoomla! Day Chicago 2011 - Templating the right way - Jonathan Shroyer
Joomla! Day Chicago 2011 - Templating the right way - Jonathan ShroyerSteven Pignataro
Ā 
How does get template part works in twenty ten theme
How does get template part works in twenty ten themeHow does get template part works in twenty ten theme
How does get template part works in twenty ten thememohd rozani abd ghani
Ā 
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
Ā 
Html5 Brown Bag
Html5 Brown BagHtml5 Brown Bag
Html5 Brown Bagstuplum
Ā 
Frontend for developers
Frontend for developersFrontend for developers
Frontend for developersHernan Mammana
Ā 
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
Ā 
Functional FIPS: Learning PHP for Drupal Theming
Functional FIPS: Learning PHP for Drupal ThemingFunctional FIPS: Learning PHP for Drupal Theming
Functional FIPS: Learning PHP for Drupal ThemingEmma Jane Hogbin Westby
Ā 
How to make a WordPress theme
How to make a WordPress themeHow to make a WordPress theme
How to make a WordPress themeHardeep Asrani
Ā 
Word Camp Fukuoka2010
Word Camp Fukuoka2010Word Camp Fukuoka2010
Word Camp Fukuoka2010YUKI YAMAGUCHI
Ā 

Similar to Grok Drupal (7) Theming - 2011 Feb update (20)

PSD to WordPress
PSD to WordPressPSD to WordPress
PSD to WordPress
Ā 
D7 theming what's new - London
D7 theming what's new - LondonD7 theming what's new - London
D7 theming what's new - London
Ā 
WordPress Theme Workshop: Part 4
WordPress Theme Workshop: Part 4WordPress Theme Workshop: Part 4
WordPress Theme Workshop: Part 4
Ā 
How to create a basic template
How to create a basic templateHow to create a basic template
How to create a basic template
Ā 
Drupal Themes
Drupal ThemesDrupal Themes
Drupal Themes
Ā 
Theming 101
Theming 101Theming 101
Theming 101
Ā 
The Way to Theme Enlightenment
The Way to Theme EnlightenmentThe Way to Theme Enlightenment
The Way to Theme Enlightenment
Ā 
Word press templates
Word press templatesWord press templates
Word press templates
Ā 
Drupal theming
Drupal themingDrupal theming
Drupal theming
Ā 
WordPress Theme Workshop: Part 3
WordPress Theme Workshop: Part 3WordPress Theme Workshop: Part 3
WordPress Theme Workshop: Part 3
Ā 
Joomla! Day Chicago 2011 - Templating the right way - Jonathan Shroyer
Joomla! Day Chicago 2011 - Templating the right way - Jonathan ShroyerJoomla! Day Chicago 2011 - Templating the right way - Jonathan Shroyer
Joomla! Day Chicago 2011 - Templating the right way - Jonathan Shroyer
Ā 
How does get template part works in twenty ten theme
How does get template part works in twenty ten themeHow does get template part works in twenty ten theme
How does get template part works in twenty ten theme
Ā 
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 ...
Ā 
Html5 Brown Bag
Html5 Brown BagHtml5 Brown Bag
Html5 Brown Bag
Ā 
Frontend for developers
Frontend for developersFrontend for developers
Frontend for developers
Ā 
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
Ā 
Functional FIPS: Learning PHP for Drupal Theming
Functional FIPS: Learning PHP for Drupal ThemingFunctional FIPS: Learning PHP for Drupal Theming
Functional FIPS: Learning PHP for Drupal Theming
Ā 
Drupal Front End PHP
Drupal Front End PHPDrupal Front End PHP
Drupal Front End PHP
Ā 
How to make a WordPress theme
How to make a WordPress themeHow to make a WordPress theme
How to make a WordPress theme
Ā 
Word Camp Fukuoka2010
Word Camp Fukuoka2010Word Camp Fukuoka2010
Word Camp Fukuoka2010
Ā 

Recently uploaded

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
Ā 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
Ā 
šŸ¬ 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
Ā 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
Ā 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
Ā 
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
Ā 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel AraĆŗjo
Ā 
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
Ā 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
Ā 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
Ā 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
Ā 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
Ā 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service šŸø 8923113531 šŸŽ° Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service šŸø 8923113531 šŸŽ° Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service šŸø 8923113531 šŸŽ° Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service šŸø 8923113531 šŸŽ° Avail...gurkirankumar98700
Ā 
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
Ā 
WhatsApp 9892124323 āœ“Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 āœ“Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 āœ“Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 āœ“Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
Ā 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
Ā 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
Ā 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
Ā 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
Ā 

Recently uploaded (20)

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
Ā 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Ā 
šŸ¬ 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)
Ā 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
Ā 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
Ā 
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
Ā 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Ā 
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
Ā 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
Ā 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
Ā 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Ā 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
Ā 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service šŸø 8923113531 šŸŽ° Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service šŸø 8923113531 šŸŽ° Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service šŸø 8923113531 šŸŽ° Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service šŸø 8923113531 šŸŽ° Avail...
Ā 
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
Ā 
WhatsApp 9892124323 āœ“Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 āœ“Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 āœ“Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 āœ“Call Girls In Kalyan ( Mumbai ) secure service
Ā 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
Ā 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
Ā 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Ā 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Ā 

Grok Drupal (7) Theming - 2011 Feb update

  • 1. Grok Drupal Theming Laura Scott PINGV @lauras #grokd4d Drupal Design Camp LA 2011
  • 2. Laura Scott Creative Director, Drupal Architect and Co-Founder PINGV Creative "laura s" drupal.org/user/18973 Drupal since 2004 @lauras
  • 3. Grok Drupal Theming Grok means to understand so thoroughly that the observer becomes a part of the observed ā€” to merge, blend, intermarry, lose identity in group experience. Robert A. Heinlein, Stranger in a Strange Land
  • 4. <h1 id="title"> Grok Drupal Theming </h1>
  • 5. <h1 id="title"> Grok Drupal Theming </h1> How Drupal displays content (templates) How to start theming Other things to consider
  • 6. Assumptions ā€¢ You know HTML/xhtml ā€¢ You don't know PHP (but if you do, we won't ā€¢ You know CSS 2.1 hold it against you) ā€¢ You are at least getting ā€¢ You understand some to know CSS 3 (or want basic Drupal to) architecture concepts ā€¢ Drupal theming confuses ā€¢ You want to learn this or mystiļ¬es you
  • 7. Some PHP required ā€¢ Mainly to print pre-deļ¬ned variables ā€¦ e.g., $title (for the page title). ā€¢ You can do a lot in the "preprocess" and "process" functions. ā€¢ You can avoid it if it totally scares the living daylights out of you. Just stick to copy and paste from '<?php' to '?>'.
  • 8. HTML5 is coming! http://groups.drupal.org/html5
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15. Theming for Drupal 7 is more powerful than previous versions ...but it's also a bit more complicated.
  • 16.
  • 17.
  • 18.
  • 19. Anatomy of a Drupal "page" ā€¢ xhtml, CSS, bg images ā€¢ Content presented via templates ā€¢ JavaScript
  • 20. The Drupal theme ā€¢ CSS ļ¬les ā€¢ Image ļ¬les ā€¢ Template ļ¬les ā€¢ JavaScript ļ¬les ā€¢ .info ļ¬le ā€¢ Preprocess and process new!
  • 21. ā€¢ CSS ļ¬les ā€¢ Image ļ¬les ā€¢ Template ļ¬les ā€¢ JavaScript ļ¬les ā€¢ Preprocess and process ļ¬les ā€¢ .info ļ¬le
  • 22. Which template? It depends....
  • 23. Which template? page.tpl.php ā€¢ logo ā€¢ main title ā€¢ regions ā€¢ footer and ā€¢ other templates
  • 24. Which template? html.tpl.php new! page.tpl.php ā€¢ !DOCTYPE ā€¢ <head> stuff ā€¢ Drupal calls for CSS and JavaScript* ā€¢ <body> container
  • 25. Which template? html.tpl.php page.tpl.php node.tpl.php ā€¢ node title ā€¢ node author ā€¢ post date ā€¢ node content ā€¢ node taxonomy terms ā€¢ node links
  • 26. Which template? html.tpl.php page.tpl.php node.tpl.php comment-wrapper.tpl.php ā€¢ Comment area title? ā€¢ Comment templates
  • 27. Which template? html.tpl.php page.tpl.php node.tpl.php comment-wrapper.tpl.php comment.tpl.php ā€¢ Comment title? ā€¢ Comment author ā€¢ Comment content ā€¢ Comment links
  • 28. Which template? html.tpl.php page.tpl.php node.tpl.php block.tpl.php ā€¢ Block title ā€¢ Block content comment-wrapper.tpl.php comment.tpl.php *We'll come back to this, because there's one more very important thing.
  • 29. Every module's output also has a template ļ¬le. (In theory.)
  • 30. 42 *.tpl.php ļ¬les in D7's /modules folder. Each can be copied into your theme and used to override.
  • 31. The Views UI gives you template code to override Views output.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36. One theme might have dozens of template ļ¬les.
  • 37.
  • 38. There are only a few basics. (It's not rocket science.)
  • 39. What's inside a template?
  • 41. html.tpl.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php print $language->language; ?>" version="XHTML+RDFa 1.0" dir="<?php print $language->dir; ?>" <?php print $rdf_namespaces; ?>>
  • 42. html.tpl.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php print $language->language; ?>" version="XHTML+RDFa 1.0" dir="<?php print $language->dir; ?>" <?php print $rdf_namespaces; ?>> <head profile="<?php print $grddl_profile; ?>"> <?php print $head; ?> <title><?php print $head_title; ?></title> <?php print $styles; ?> <?php print $scripts; ?> </head>
  • 43. html.tpl.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php print $language->language; ?>" version="XHTML+RDFa 1.0" dir="<?php print $language->dir; ?>" <?php print $rdf_namespaces; ?>> <head profile="<?php print $grddl_profile; ?>"> <?php print $head; ?> <title><?php print $head_title; ?></title> <?php print $styles; ?> <?php print $scripts; ?> </head> <body class="<?php print $classes; ?>" <?php print $attributes;?>> <div id="skip-link"> <a href="#main-content" class="element-invisible element-focusable"><?php print t('Skip to main content'); ?></a> </div> <?php print $page_top; ?> <?php print $page; ?> <?php print $page_bottom; ?> </body> </html>
  • 44. <body class="<?php print $classes; ?>" <?php print $attributes;?>> <div id="skip-link"> <a href="#main-content" class="element-invisible element-focusable"><?php print t('Skip to main content'); ?></a> </div> <?php print $page_top; ?> <?php print $page; ?> <?php print $page_bottom; ?> </body> </html>
  • 46. page.tpl.php <div id="page-wrapper"><div id="page"> <div id="header"><div class="section clearfix"> <?php if ($logo): ?> <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home" id="logo"> logo <img src="<?php print $logo; ?>" alt="<?php print t('Home'); ?>" /> site name </a> <?php endif; ?> <?php if ($site_name || $site_slogan): ?> <div id="name-and-slogan"> <?php if ($site_name): ?> <?php if ($title): ?> site slogan <div id="site-name"><strong> <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home"><span><?php print $site_name; ?></span></a> </strong></div> <?php else: /* Use h1 when the content title is empty */ ?> <h1 id="site-name"> main menu <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home"><span><?php print $site_name; ?></span></a> </h1> <?php endif; ?> <?php endif; ?> <?php if ($site_slogan): ?> breadcrumb <div id="site-slogan"><?php print $site_slogan; ?></div> <?php endif; ?> </div> <!-- /#name-and-slogan --> <?php endif; ?> <?php print render($page['header']); ?> messages </div></div> <!-- /.section, /#header --> <?php if ($main_menu): ?> <div id="navigation"><div class="section"> <?php print theme('links__system_main_menu', array('links' => $main_menu, 'attributes' => array('id' => 'main-menu', 'class' => array('links', 'clearfix')), 'heading' => t('Main menu'))); ?> highight </div></div> <!-- /.section, /#navigation --> <?php endif; ?> <?php if ($breadcrumb): ?> <div id="breadcrumb"><?php print $breadcrumb; ?></div> <?php endif; ?> <h1> title <?php print $messages; ?> <div id="main-wrapper"><div id="main" class="clearfix"> <div id="content" class="column"><div class="section"> tabs <?php if ($page['highlight']): ?><div id="highlight"><?php print render($page['highlight']); ?></div><?php endif; ?> <a id="main-content"></a> <?php print render($title_prefix); ?> <?php if ($title): ?><h1 class="title" id="page-title"><?php print $title; ?></h1><?php endif; ?> <?php print render($title_suffix); ?> <?php if ($tabs): ?><div class="tabs"><?php print render($tabs); ?></div><?php endif; ?> help <?php print render($page['help']); ?> <?php if ($action_links): ?><ul class="action-links"><?php print render($action_links); ?></ul><?php endif; ?> <?php print render($page['content']); ?> <?php print $feed_icons; ?> </div></div> <!-- /.section, /#content --> content <?php if ($page['sidebar_first']): ?> <div id="sidebar-first" class="column sidebar"><div class="section"> <?php print render($page['sidebar_first']); ?> </div></div> <!-- /.section, /#sidebar-first --> <?php endif; ?> <?php if ($page['sidebar_second']): ?> <div id="sidebar-second" class="column sidebar"><div class="section"> <?php print render($page['sidebar_second']); ?> </div></div> <!-- /.section, /#sidebar-second --> feed icons <?php endif; ?> </div></div> <!-- /#main, /#main-wrapper --> <div id="footer"><div class="section"> <?php print theme('links__system_secondary_menu', array('links' => $secondary_menu, 'attributes' => array('id' => sidebars footer 'secondary-menu', 'class' => array('links', 'clearfix')), 'heading' => t('Secondary menu'))); ?> <?php print render($page['footer']); ?> </div></div> <!-- /.section, /#footer --> </div></div> <!-- /#page, /#page-wrapper -->
  • 47. The Semantic Page ā€¢ Logo/branding/site name ā€¢ [main nav]* ā€¢ <h1> Title (of article, view, blog post, etc.) ā€¢ Main content ā€¢ Then secondary content (aka "sidebars"), footer * and that's debated
  • 48. <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home"><span><? php print $site_name; ?></span></a> page.tpl.php </h1> <?php endif; ?> <?php endif; ?> <?php if ($site_slogan): ?> <div id="site-slogan"><?php print $site_slogan; ?></div> <?php endif; ?> </div> <!-- /#name-and-slogan --> <?php endif; ?> <?php print render($page['header']); ?> </div></div> <!-- /.section, /#header --> <?php if ($main_menu): ?> <div id="navigation"><div class="section"> <?php print theme('links__system_main_menu', array('links' => $main_menu, 'attributes' => array('id' => 'main-menu', 'class' => array('links', 'clearfix')), 'heading' => t('Main menu'))); ?> </div></div> <!-- /.section, /#navigation --> <?php endif; ?> <?php if ($breadcrumb): ?> <div id="breadcrumb"><?php print $breadcrumb; ?></div> <?php endif; ?> <?php print $messages; ?> <div id="main-wrapper"><div id="main" class="clearfix"> <div id="content" class="column"><div class="section"> <?php if ($page['highlight']): ?><div id="highlight"><?php print render($page['highlight']); ?></ div><?php endif; ?> <a id="main-content"></a> <?php print render($title_prefix); ?> <?php if ($title): ?><h1 class="title" id="page-title"><?php print $title; ?></h1><?php endif; ?> <?php print render($title_suffix); ?> <?php if ($tabs): ?><div class="tabs"><?php print render($tabs); ?></div><?php endif; ?> <?php print render($page['help']); ?> <?php if ($action_links): ?><ul class="action-links"><?php print render($action_links); ?></ul><?php endif; ?> <?php print render($page['content']); ?> <?php print $feed_icons; ?> </div></div> <!-- /.section, /#content --> <?php if ($page['sidebar_first']): ?> <div id="sidebar-first" class="column sidebar"><div class="section"> <?php print render($page['sidebar_first']); ?> </div></div> <!-- /.section, /#sidebar-first --> <?php endif; ?> <?php if ($page['sidebar_second']): ?> <div id="sidebar-second" class="column sidebar"><div class="section"> <?php print render($page['sidebar_second']); ?> </div></div> <!-- /.section, /#sidebar-second --> <?php endif; ?> </div></div> <!-- /#main, /#main-wrapper --> <div id="footer"><div class="section"> <?php print theme('links__system_secondary_menu', array('links' => $secondary_menu, 'attributes' => array('id' => 'secondary-menu', 'class' => array('links', 'clearfix')), 'heading' => t('Secondary menu'))); ?> <?php print render($page['footer']); ?> </div></div> <!-- /.section, /#footer -->
  • 49. <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home"><span><? php print $site_name; ?></span></a> page.tpl.php </h1> <?php endif; ?> <?php endif; ?> <?php if ($site_slogan): ?> <div id="site-slogan"><?php print $site_slogan; ?></div> <?php endif; ?> </div> <!-- /#name-and-slogan --> <?php endif; ?> <?php print render($page['header']); ?> </div></div> <!-- /.section, /#header --> <?php print $messages; ?> <div id="main-wrapper"><div id="main" class="clearfix"> <div id="content" class="column"><div class="section"> <?php if ($page['highlight']): ?><div id="highlight"><?php print render($page['highlight']); ?></ div><?php endif; ?> <a id="main-content"></a> <?php print render($title_prefix); ?> <?php if ($title): ?><h1 class="title" id="page-title"><?php print $title; ?></h1><?php endif; ?> <?php print render($title_suffix); ?> <?php if ($tabs): ?><div class="tabs"><?php print render($tabs); ?></div><?php endif; ?> <?php print render($page['help']); ?> <?php if ($action_links): ?><ul class="action-links"><?php print render($action_links); ?></ul><?php endif; ?> <?php print render($page['content']); ?> <?php print $feed_icons; ?> </div></div> <!-- /.section, /#content --> <?php if ($page['sidebar_first']): ?> <div id="sidebar-first" class="column sidebar"><div class="section"> <?php print render($page['sidebar_first']); ?> </div></div> <!-- /.section, /#sidebar-first --> <?php endif; ?> <?php if ($page['sidebar_second']): ?> <div id="sidebar-second" class="column sidebar"><div class="section"> <?php print render($page['sidebar_second']); ?> </div></div> <!-- /.section, /#sidebar-second --> <?php endif; ?> </div></div> <!-- /#main, /#main-wrapper --> <?php if ($main_menu): ?> <div id="navigation"><div class="section"> <?php print theme('links__system_main_menu', array('links' => $main_menu, 'attributes' => array('id' => 'main-menu', 'class' => array('links', 'clearfix')), 'heading' => t('Main menu'))); ?> </div></div> <!-- /.section, /#navigation --> <?php endif; ?> <?php if ($breadcrumb): ?> <div id="breadcrumb"><?php print $breadcrumb; ?></div> <?php endif; ?> <div id="footer"><div class="section"> <?php print theme('links__system_secondary_menu', array('links' => $secondary_menu, 'attributes' => array('id' => 'secondary-menu', 'class' => array('links', 'clearfix')), 'heading' => t('Secondary menu'))); ?> <?php print render($page['footer']); ?> </div></div> <!-- /.section, /#footer -->
  • 51. node.tpl.php <div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>> <?php print $user_picture; ?> <?php print render($title_prefix); ?> <?php if (!$page): ?> <h2<?php print $title_attributes; ?>><a href="<?php print $node_url; ? >"><?php print $title; ?></a></h2> <?php endif; ?> <?php print render($title_suffix); ?> <?php if ($display_submitted): ?> <div class="submitted"> <?php print t('Submitted by !username on !datetime', array('!username' => $name, '!datetime' => $date)); ?> </div> <?php endif; ?> <div class="content"<?php print $content_attributes; ?>> <?php // We hide the comments and links now so that we can render them later. hide($content['comments']); hide($content['links']); print render($content); ?> </div> <?php print render($content['links']); ?> <?php print render($content['comments']); ?> </div>
  • 52. node.tpl.php <div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>> <?php print $user_picture; ?> <?php print render($title_prefix); ?> <?php if (!$page): ?> <h2<?php print $title_attributes; ?>><a href="<?php print $node_url; ? >"><?php print $title; ?></a></h2> <?php endif; ?> <?php print render($title_suffix); ?> <?php if ($display_submitted): ?> <div class="submitted"> <?php print t('Submitted by !username on !datetime', array('!username' => $name, '!datetime' => $date)); ?> </div> <?php endif; ?> <div class="content"<?php print $content_attributes; ?>> <?php // We hide the comments and links now so that we can render them later. hide($content['comments']); hide($content['links']); print render($content); ?> </div> <?php print render($content['links']); ?> <?php print render($content['comments']); ?> new! </div>
  • 54. comment-wrapper.tpl.php <div id="comments" class="<?php print $classes; ?>"<?php print $attributes; ?>> <?php if ($content['comments'] && $node->type != 'forum'): ?> <?php print render($title_prefix); ?> <h2 class="title"><?php print t('Comments'); ?></h2> <?php print render($title_suffix); ?> <?php endif; ?> <?php print render($content['comments']); ?> <?php if ($content['comment_form']): ?> <h2 class="title comment-form"><?php print t('Add new comment'); ?></h2> <?php print render($content['comment_form']); ?> <?php endif; ?> </div>
  • 56. comment.tpl.php <div class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>> <?php print $picture ?> <?php if ($new): ?> <span class="new"><?php print $new ?></span> <?php endif; ?> <?php print render($title_prefix); ?> <h3<?php print $title_attributes; ?>><?php print $title ?></h3> <?php print render($title_suffix); ?> <div class="submitted"> <?php print $permalink; ?> <?php print $submitted; ?> </div> <div class="content"<?php print $content_attributes; ?>> <?php // We hide the comments and links now so that we can render them later. hide($content['links']); print render($content); ?> <?php if ($signature): ?> <div class="user-signature clearfix"> <?php print $signature ?> </div> <?php endif; ?> </div> <?php print render($content['links']) ?> </div>
  • 58. block.tpl.php <div id="<?php print $block_html_id; ?>" class="<?php print $classes; ?>"<?php print $attributes; ?>> <?php print render($title_prefix); ?> <?php if ($block->subject): ?> <h2<?php print $title_attributes; ?>><?php print $block->subject ?></h2> <?php endif;?> <?php print render($title_suffix); ?> <div class="content"<?php print $content_attributes; ? >> <?php print $content ?> </div> </div>
  • 59. block.tpl.php <div id="<?php print $block_html_id; ?>" class="<?php print $classes; ?>"<?php print $attributes; ?>> <?php print render($title_prefix); ?> <?php if ($block->subject): ?> <h2<?php print $title_attributes; ?>><?php print $block->subject ?></h2> <?php endif;?> <?php print render($title_suffix); ?> <div class="content"<?php print $content_attributes; ? >> <?php print $content ?> </div> </div>
  • 60. polls
  • 61. node.tpl.php node.tpl.php poll-vote.tpl.php poll-results.tpl.php poll-bar.tpl.php
  • 62. block.tpl.php block.tpl.php poll-vote.tpl.php poll-results--block.tpl.php poll-bar--block.tpl.php
  • 63. Fields are in core It's nice to have a home.
  • 65. ļ¬eld.tpl.php <div class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>> <?php if (!$label_hidden) : ?> <div class="field-label"<?php print $title_attributes; ?>><?php print $label ?>:&nbsp;</div> <?php endif; ?> <div class="field-items"<?php print $content_attributes; ?>> <?php foreach ($items as $delta => $item) : ?> <div class="field-item <?php print $delta % 2 ? 'odd' : 'even'; ?>"<?php print $item_attributes [$delta]; ?>><?php print render($item); ?></div> <?php endforeach; ?> </div> </div>
  • 66.
  • 67. html.tpl.php page.tpl.php node.tpl.php block.tpl.php comment-wrapper.tpl.php comment.tpl.php
  • 68. html.tpl.php page.tpl.php region.tpl.php region.tpl.php region.tpl.php node.tpl.php block.tpl.php comment-wrapper.tpl.php comment.tpl.php region.tpl.php
  • 70. region.tpl.php <?php if ($content): ?> <div class="<?php print $classes; ?>"> <?php print $content; ?> </div> <?php endif; ?>
  • 71. So if all regions use the same template, how does Drupal know which region?
  • 72.
  • 74. <?php print render($page['header']); ?> <?php print render($page['help']); ?> <?php print render($page['highlight']); ?> <?php print render($page['content']); ?> <?php print render($page['sidebar_first']); ?> <?php print render($page['sidebar_second']); ?> <?php print render($page['footer']); ?>
  • 75. All regions in your theme must be declared, or else you get these defaults.
  • 76. Where the heck are all these templates?
  • 78.
  • 80.
  • 81. Everything is an array pretty much
  • 82. So how to go about creating a theme?
  • 83. Create a theme from scratch, making everything ā€¢ theme .info ļ¬le ā€¢ page.tpl.php ā€¢ *.tpl.php ļ¬les as needed to override core ā€¢ template.php for your preprocess and process ā€¢ background images
  • 84. or make a baby!
  • 87. Inheritance html.tpl.php page.tpl.php page.tpl.php node.tpl.php node.tpl.php block.tpl.php
  • 88. Inheritance html.tpl.php html.tpl.php page.tpl.php page.tpl.php node.tpl.php node.tpl.php block.tpl.php
  • 89. Inheritance base.css base.css type.css type.css forms.css
  • 90. Many good base themes
  • 91. Copy in the base theme example.com/themes/ example.com/sites/all/themes/basetheme
  • 92. Create your child theme example.com/themes/ example.com/sites/all/themes/yourtheme
  • 93. sites all themes yourtheme yourtheme.info template.php license.txt css images templates
  • 95. yourtheme.info name = yourtheme description = This is where you describe your theme in words. version = 1.0 ; Requirements base theme = ninesixty core = 7.x engine = phptemplate ; Stylesheets stylesheets[all][] = styles.css stylesheets[screen][] = styles/base.css stylesheets[screen][] = styles/layout.css stylesheets[screen][] = styles/colors.css stylesheets[screen][] = styles/forms.css stylesheets[print][] = styles/print.css ; Regions regions[header] = Header regions[help] = Help regions[highlight] = Highlight regions[content] = Content regions[page_top] = Page top regions[page_bottom] = Page bottom regions[indicators] = Indicators regions_hidden[] = indicators ; Scripts scripts[] = script.js scripts[] = scripts/twitter.js
  • 96. yourtheme.info name = yourtheme description = This is where you describe your theme in words. version = 1.0 ; Requirements base theme = ninesixty core = 7.x engine = phptemplate ; Stylesheets stylesheets[all][] = styles.css stylesheets[screen][] = styles/base.css stylesheets[screen][] = styles/layout.css stylesheets[screen][] = styles/colors.css stylesheets[screen][] = styles/forms.css stylesheets[print][] = styles/print.css ; Regions regions[header] = Header regions[help] = Help regions[highlight] = Highlight regions[content] = Content regions[page_top] = Page top regions[page_bottom] = Page bottom regions[indicators] = Indicators regions_hidden[] = indicators ; Scripts scripts[] = script.js scripts[] = scripts/twitter.js
  • 97. In Drupal 7, if you're creating a theme from scratch, you must now declare style.css and script.js in your .info ļ¬le, or they will not be included.
  • 98. yourtheme.info name = yourtheme description = This is where you describe your theme in words. version = 1.0 ; Requirements base theme = ninesixty core = 7.x engine = phptemplate ; Stylesheets stylesheets[all][] = styles.css stylesheets[screen][] = styles/base.css stylesheets[screen][] = styles/layout.css stylesheets[screen][] = styles/colors.css stylesheets[screen][] = styles/forms.css stylesheets[print][] = styles/print.css ; Regions regions[header] = Header regions[help] = Help regions[highlight] = Highlight regions[content] = Content regions[page_top] = Page top regions[page_bottom] = Page bottom regions[indicators] = Indicators regions_hidden[] = indicators ; Scripts scripts[] = script.js scripts[] = scripts/twitter.js
  • 99. Template Suggestions ā€¢ Create a base template of that type ā€¢ Create variations on it to apply in certain circumstances ā€¢ No coding necessary http://drupal.org/node/190815
  • 100. Template Suggestions by content type node.tpl.php blog node--blog.tpl.php event node--event.tpl.php classiļ¬ed node--classiļ¬ed.tpl.php product node--product.tpl.php
  • 101. Template Suggestions by content type new! node.tpl.php blog node--blog.tpl.php event node--event.tpl.php classiļ¬ed node--classiļ¬ed.tpl.php product node--product.tpl.php
  • 102. Delimiters use two: '--' Words still use one: '-' event-meeting node--event-meeting.tpl.php event-party node--event-party.tpl.php
  • 103. new! And no longer need node.tpl.php in your theme in order to use node--event.tpl.php.
  • 104. new! Wildcards in tpl names page--user--42.tpl.php page--user--%.tpl.php override all user displays without affecting /user
  • 105. new! .clear-block is now .clearļ¬x
  • 107. Conditional CSS still needs trickery //IE6 overrides drupal_add_css( path_to_theme() . '/fix-ie.css', array( 'group' => CSS_THEME, 'browsers' => array( 'IE' => 'lt IE 7', '!IE' => FALSE ), 'preprocess' => FALSE ) );
  • 108. new! Classes and Attributes are now standard and predeļ¬ned without futzing (although you can still futz if you want).
  • 109. <div id="example" class="<?php print $classes; ?> clearļ¬x"<?php print $attributes; ?>> ... </div>
  • 110. node.tpl.php <div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?> clearļ¬x"<?php print $attributes; ?>> ... </div>
  • 111. Attributes new! ā€¢ $attributes ā€¢ $title_attributes for titles ā€¢ $content_attributes for content
  • 112. <div id="example" class="<?php print $classes; ?>"<?php print $attributes; ?>> <h2<?php print $title_attributes; ?>>...</h2> <div class="content"<?php print $content_attributes; ?>> ... </div> </div>
  • 113. Be nice to robots! photo: Don Solo ļ¬‚ickr.com/photos/donsolo/3950364004/
  • 114. RDFa ā€¢ Robot food ā€¢ An entire language to learn ā€¢ Theming just got a lot more technical photo: Don Solo ļ¬‚ickr.com/photos/donsolo/3950364004/
  • 116. Robots just want to Hand over I'm hungry! your RDF! understand your site. Hmmmmmā€¦. dataā€¦.. Image: bbaltimore ļ¬‚ickr.com/photos/bbaltimore/6778028/
  • 117. Dance with them! It's easy! Image: Eric__I_E ļ¬‚ickr.com/photos/deadling/256390679/
  • 118. html.tpl.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml- rdfa-1.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php print $language->language; ?>" version="XHTML+RDFa 1.0" dir="<?php print $language->dir; ?>" <?php print $rdf_namespaces; ?>>
  • 119. html.tpl.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml- rdfa-1.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php print $language->language; ?>" version="XHTML+RDFa 1.0" dir="<?php print $language->dir; ?>" <?php print $rdf_namespaces; ?>>
  • 120. html.tpl.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml- rdfa-1.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php print $language->language; ?>" version="XHTML+RDFa 1.0" dir="<?php print $language->dir; ?>" <?php print $rdf_namespaces; ?>>
  • 121. html.tpl.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml- rdfa-1.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php print $language->language; ?>" version="XHTML+RDFa 1.0" dir="<?php print $language->dir; ?>" <?php print $rdf_namespaces; ?>>
  • 122. html.tpl.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml- rdfa-1.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php print $language->language; ?>" version="XHTML+RDFa 1.0" dir="<?php print $language->dir; ?>" <?php print $rdf_namespaces; ?>>
  • 123. html.tpl.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml- rdfa-1.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php print $language->language; ?>" version="XHTML+RDFa 1.0" dir="<?php print $language->dir; ?>" <?php print $rdf_namespaces; ?>> <head profile="<?php print $grddl_profile; ? >">
  • 124. Do I really need to do RDFa to use Drupal? No, you can just ignore it, and work on the same level as other systems. But you'll be missing out. Photo: FlySi ļ¬‚ickr.com/photos/ļ¬‚ysi/183272970/
  • 125. Attributes ā€¢ $attributes ā€¢ $title_attributes for titles ā€¢ $content_attributes for content
  • 126. Basics to Remember ā€¢ Create your theme in sites/all/themes/yourtheme ā€¢ Copy templates into your theme to make overrides ā€¢ Use template suggestions to break out distinct structures and stylings ā€¢ Use base theme to get a jump on things ā€¢ Let Drupal do what it does best
  • 127. Points of Modiļ¬cation ā€¢ CSS ā€¢ xhtml in the template that applies ā€¢ preprocess ā€¢ module
  • 128. Resources ā€¢ Drupal 6 Ā» Drupal 7 theming changes drupal.org/update/theme/6/7 ā€¢ Template suggestions drupal.org/node/190815* ā€¢ RDFa buytaert.net/semantic-web- and-drupal-video * Drupal 6
  • 129.
  • 130. Get Drush! Yeah yeah yeah, I know, you don't like command line, but this will really really and for true help you save time developing so that you can spend more time designing and theming, and isn't that what you'd rather do anyway? Video to make it easy: http://is.gd/ aZe33
  • 131. @lauras rarepattern.com/contact Ā©2010 Laura Scott
  • 132. Questions? @lauras