SlideShare a Scribd company logo
TEMPLATING THE RIGHT WAY


                   by Jonathan Shroyer
                           Twitter: @learncss
              Email: jonathan@corephp.com
               by Jonathan Shroyer
TEMPLATE
 BASICS
DID YOU KNOW?
DID YOU KNOW?




Tables are for tabular
data... not for layouts
PROPER HEADINGS
PROPER HEADINGS

• H tags are possibly most important for SEOs
PROPER HEADINGS

• H tags are possibly most important for SEOs

• One H1 per page
PROPER HEADINGS

• H tags are possibly most important for SEOs

• One H1 per page

• Opening page H1 should be company name
  and tagline/short description.
PROPER HEADINGS

• H tags are possibly most important for SEOs

• One H1 per page

• Opening page H1 should be company name
  and tagline/short description.

• H1 tags on all inner pages should be article
  title.
PROPER HEADINGS

• H tags are possibly most important for SEOs

• One H1 per page

• Opening page H1 should be company name
  and tagline/short description.

• H1 tags on all inner pages should be article
  title.

• NEVER skip a tag! (ie. H2 to H4)
LOGO CODE FOR YOUR
     TEMPLATE
LOGO CODE FOR YOUR
         TEMPLATE

if( JURI::current() == JURI::base() ) { ?>
  <h1 id="company-logo">
    <a href="<?php echo JURI::base(); ?>">
      Company Name
    </a>
  </h1>
LOGO CODE FOR YOUR
     TEMPLATE
LOGO CODE FOR YOUR
          TEMPLATE

} else {
    <p id="company-logo">
     <a href="<?php echo JURI::base(); ?>">
       Company Name
     </a>
    </p>
}
HEADINGS INSIDE OF YOUR
      TEMPLATE
HEADINGS INSIDE OF YOUR
       TEMPLATE

• In your overrides you should use the same logic:
  if( JURI::current() == JURI::base() ) {
      $h = 2;
  } else {
      $h = 1;
  }
  <h<?php echo $h; ?>>Title</h<?php echo $h; ?>}
HEADINGS INSIDE OF YOUR
       TEMPLATE

• In your overrides you should use the same logic:
  if( JURI::current() == JURI::base() ) {
      $h = 2;
  } else {
      $h = 1;
  }
  <h<?php echo $h; ?>>Title</h<?php echo $h; ?>}

• Module titles are virtually always H2
IMAGES
IMAGES


• Use alt tags on images which you want people to
  know what it is. (ie. If image wasn't there, would
  the description add to the content?)
IMAGES


• Use alt tags on images which you want people to
  know what it is. (ie. If image wasn't there, would
  the description add to the content?)

• Learn how to size images properly and how to
  compress them. Extra size slows down site and
  can lower SEO value.
WHAT ABOUT HTML5?
WHAT ABOUT HTML5?

• No SEO advantage at this time
WHAT ABOUT HTML5?

• No SEO advantage at this time

• Personally don’t recommend it as support is
  less than HTML4.
WHAT ABOUT HTML5?

• No SEO advantage at this time

• Personally don’t recommend it as support is
  less than HTML4.

• Only use if you have a specific market that you
  know has the capability to properly display it.
WHAT ABOUT HTML5?

• No SEO advantage at this time

• Personally don’t recommend it as support is
  less than HTML4.

• Only use if you have a specific market that you
  know has the capability to properly display it.

• It’s a great movement, but it’s really still the
  Wild Wild West.
NOT-SO-BASIC
TEMPLATE BASICS
LEARN THE JOOMLA LANGUAGE
LEARN THE JOOMLA LANGUAGE




• Why should you learn the Joomla! library for
  template development?
LEARN THE JOOMLA LANGUAGE




• Why should you learn the Joomla! library for
  template development?

  • Allows you to do advanced logic with your
    template.
LEARN THE JOOMLA LANGUAGE




• Why should you learn the Joomla! library for
  template development?

  • Allows you to do advanced logic with your
    template.

  • Gives you options you never had before
LEARN THE JOOMLA LANGUAGE
LEARN THE JOOMLA LANGUAGE


• JHTML
LEARN THE JOOMLA LANGUAGE


• JHTML

 • link, image, iframe, date, tooltip, calendar, etc.
LEARN THE JOOMLA LANGUAGE


• JHTML

 • link, image, iframe, date, tooltip, calendar, etc.

 • Example:
   $link = JHTML::_('image', 'images/stories/clock.jpg',
   null);
   echo $link;
LEARN THE JOOMLA LANGUAGE


• JHTML

  • link, image, iframe, date, tooltip, calendar, etc.

  • Example:
    $link = JHTML::_('image', 'images/stories/clock.jpg',
    null);
    echo $link;

• http://api.joomla.org/__filesource/fsource_Joomla-
  Framework_HTML_joomlahtmlhtml.php.html#a191
ADDING EXTERNAL
CSS STYLESHEETS (JOOMLA 1.6+)
ADDING EXTERNAL
CSS STYLESHEETS (JOOMLA 1.6+)

• $doc = JFactory::getDocument();
  $path = 'templates/' .
    $this->template . '/css/mystylesheet.css';

  $doc->addStyleSheet( $path,
    , ‘text/css’, “screen, projection” );
ADDING EXTERNAL
CSS STYLESHEETS (JOOMLA 1.6+)

• $doc = JFactory::getDocument();
  $path = 'templates/' .
    $this->template . '/css/mystylesheet.css';

  $doc->addStyleSheet( $path,
    , ‘text/css’, “screen, projection” );
• You can also use:
  JHTML::stylesheet( $path,
  array('media'=>'screen, projection' ) );
ADDING CSS STYLES
   FOR ONLY IE
ADDING CSS STYLES
         FOR ONLY IE


$stylelink = '' ."n";

$doc =& JFactory::getDocument();
$doc->addCustomTag($stylelink);
MAKE YOUR TEMPLATE
    UPGRADABLE
In templateDetails.xml the opening is:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE install PUBLIC "-//Joomla! 1.6//
DTD template 1.0//EN" "http://
www.joomla.org/xml/dtd/1.6/template-
install.dtd">
<extension version="1.7" type="template"
client="site" method=”upgrade”>
BUILDING BLOCKS
   USING CSS
SIZE BOX
SIZE BOX


grid_size boxes are used for width, height and overall
positioning of box.
SIZE BOX


grid_size boxes are used for width, height and overall
positioning of box.
SIZE BOX


grid_size boxes are used for width, height and overall
positioning of box.

.grid_size {
  width: 100%;
  height: auto;
  float: left;
  display: inline;
  position: relative; }
SIZE BOX


grid_size boxes are used for width, height and overall
positioning of box.

.grid_size {
  width: 100%;
  height: auto;
  float: left;
  display: inline;
  position: relative; }
STYLE BOX
STYLE BOX

grid_style boxes are used for padding, borders and
positioning of content within box.
STYLE BOX

grid_style boxes are used for padding, borders and
positioning of content within box.
STYLE BOX

grid_style boxes are used for padding, borders and
positioning of content within box.

.grid_style {
  width: auto;
  height: auto;
  display: block;
  top: 0;
  left: 0;
  clear: both; }
STYLE BOX

grid_style boxes are used for padding, borders and
positioning of content within box.

.grid_style {
  width: auto;
  height: auto;
  display: block;
  top: 0;
  left: 0;
  clear: both; }
EXAMPLE BOX
EXAMPLE BOX


<div class=”grid_size”>
EXAMPLE BOX


<div class=”grid_size”>
  <div class=”grid_style”>
EXAMPLE BOX


<div class=”grid_size”>
  <div class=”grid_style”>
     CSS Box
EXAMPLE BOX


<div class=”grid_size”>
  <div class=”grid_style”>
     CSS Box
  </div>
EXAMPLE BOX


<div class=”grid_size”>
   <div class=”grid_style”>
     CSS Box
   </div>
 </div>
EXAMPLE BOX


<div class=”grid_size”>
   <div class=”grid_style”>
     CSS Box
   </div>
 </div>
GETTING CONTROL
OF YOUR TEMPLATE
ADD AS MANY VARIABLES AS
POSSIBLE TO BODY TAG CLASS
ADD AS MANY VARIABLES AS
POSSIBLE TO BODY TAG CLASS
 <?php
 $body = '';
 if( JRequest::getInt( 'Itemid' ) ) {
       $body .= 'itemid-'.JRequest::getInt( 'Itemid' );
 }
 if( JRequest::getInt( 'id' ) ) {
       $body .= ' id-'.JRequest::getInt( 'id' );
 }
 if( JRequest::getVar( 'task' ) ) {
       $body .= ' task-'.JRequest::getVar( 'task' );
 }
ADD AS MANY VARIABLES AS
POSSIBLE TO BODY TAG CLASS
ADD AS MANY VARIABLES AS
POSSIBLE TO BODY TAG CLASS
if( JRequest::getVar( 'view' ) ) {
     $body .= ' view-'.JRequest::getVar( 'view' );
}
if( JRequest::getVar( 'layout' ) ) {
     $body .= ' layout-'.JRequest::getVar( 'layout' );
}
if( JRequest::getVar( 'option' ) ) {
     $body .= ' option-'.JRequest::getVar( 'option' );
}
ADD AS MANY VARIABLES AS
POSSIBLE TO BODY TAG CLASS
ADD AS MANY VARIABLES AS
POSSIBLE TO BODY TAG CLASS



$body .= ' lang-' . $this->language;
$body .= ' direction-' . $this->direction;
if( JURI::current() == JURI::base() ) {
     $body .= ' frontpage’;
}
Joomla! Day Chicago 2011 - Templating the right way - Jonathan Shroyer
global $mainframe;
$menu = @$mainframe->getMenu();
$active = @$menu->getActive();
while ( $active->parent > 0 ) {
    $parent = $menu->getItem(
    $active->parent );
    if ( 0 == $parent->parent ) {
        $top_level = $parent;
       break;
    } else {
       $active = $parent;
    }
}
$body .= ' menu_parent-' . $active->id;
Joomla! Day Chicago 2011 - Templating the right way - Jonathan Shroyer
$user =& JFactory::getUser();
$userGroups = $user->groups;
foreach($userGroups as $key => $value){
    $replace = array(".", " ");
    $body .= ' group-' .
strtolower( str_replace( $replace, '_', $key ) );
}
HOW THE VARIABLES OUTPUT
HOW THE VARIABLES OUTPUT



<body class=”<?php echo $body; ?>”>

Outputs:
<body class=”itemid-257 id-6 view-article option-
com_content lang-en-gb direction-ltr frontpage
menu_parent-1 group-super_users”>
HOW WOULD YOU USE THE
  MENU_PARENT CODE?
HOW WOULD YOU USE THE
        MENU_PARENT CODE?

In the CSS you could use it to change the
sidebar color for each parent menu and inherit
into each child.

.menu_parent-1 #sidebar {
    background: #ccc;
}

You can stack body classes safely:
.view-article.menu_parent-1 #sidebar
DOING DYNAMIC
 THE RIGHT WAY
LOAD DYNAMIC CSS
  INTO THE HEAD
LOAD DYNAMIC CSS
        INTO THE HEAD

Don’t create external php css files. Instead
do this...
LOAD DYNAMIC CSS
        INTO THE HEAD

Don’t create external php css files. Instead
do this...
$doc =& JFactory::getDocument();
$style = 'BODY {'
   . 'background: #00ff00;'
   . 'color: rgb(0,0,255);'
   . '}';
$doc->addStyleDeclaration( $style );
A FEW NOTES ABOUT
CREATING JOOMLA!
   1.7+ TEMPLATES
CREATING A NEW TEMPLATE
CREATING A NEW TEMPLATE



• Templates will not show up in Template
  Manager without being installed
CREATING A NEW TEMPLATE



• Templates will not show up in Template
  Manager without being installed
• Clicking Discover in Extension Manager
  will make templates show in Templates tab
  in Template Manager, but not in Styles
Joomla! Day Chicago 2011 - Templating the right way - Jonathan Shroyer
SETTING/REMOVING SCRIPTS
SETTING/REMOVING SCRIPTS

Add this above your DOCTYPE
SETTING/REMOVING SCRIPTS

  Add this above your DOCTYPE
• JHtml::_('behavior.framework', false);
SETTING/REMOVING SCRIPTS

  Add this above your DOCTYPE
• JHtml::_('behavior.framework', false);
    • FALSE = just mootools core (89KB)
SETTING/REMOVING SCRIPTS

  Add this above your DOCTYPE
• JHtml::_('behavior.framework', false);
    • FALSE = just mootools core (89KB)
    • TRUE = mootools-core + mootools-more (89KB +
      238KB = 327KB!)
SETTING/REMOVING SCRIPTS

  Add this above your DOCTYPE
• JHtml::_('behavior.framework', false);
    • FALSE = just mootools core (89KB)
    • TRUE = mootools-core + mootools-more (89KB +
      238KB = 327KB!)
  To remove all scripts:
SETTING/REMOVING SCRIPTS

  Add this above your DOCTYPE
• JHtml::_('behavior.framework', false);
    • FALSE = just mootools core (89KB)
    • TRUE = mootools-core + mootools-more (89KB +
      238KB = 327KB!)
  To remove all scripts:
• $doc =& JFactory::getDocument();
  $doc->_scripts = array();
SETTING/REMOVING SCRIPTS

  Add this above your DOCTYPE
• JHtml::_('behavior.framework', false);
    • FALSE = just mootools core (89KB)
    • TRUE = mootools-core + mootools-more (89KB +
      238KB = 327KB!)
  To remove all scripts:
• $doc =& JFactory::getDocument();
  $doc->_scripts = array();
  This is not recommended!
REMOVING MOOTOOLS IN 1.7
REMOVING MOOTOOLS IN 1.7

$user =& JFactory::getUser();
if ( $user->get( 'guest' ) == 1 ) {
      $document =& JFactory::getDocument();
      $headerstuff = $document->getHeadData();
      reset($headerstuff['scripts']);
      foreach ($headerstuff['scripts'] as $key=>$value){
        if (substr_count($key, 'mootools') > 0)
           unset($headerstuff['scripts'][$key]);
      }
      $document->setHeadData( $headerstuff );
}
MAKE IT SMALLER...
  AND FASTER!
KEY POINTS FOR SPEEDING
   UP YOUR TEMPLATE
KEY POINTS FOR SPEEDING
     UP YOUR TEMPLATE
• Optimize your images
KEY POINTS FOR SPEEDING
     UP YOUR TEMPLATE
• Optimize your images

• Make sprites with your images
KEY POINTS FOR SPEEDING
     UP YOUR TEMPLATE
• Optimize your images

• Make sprites with your images

• Combine CSS and JavaScript into one file for
  each
KEY POINTS FOR SPEEDING
     UP YOUR TEMPLATE
• Optimize your images

• Make sprites with your images

• Combine CSS and JavaScript into one file for
  each

• Don't use "on the fly" compression plugins
KEY POINTS FOR SPEEDING
     UP YOUR TEMPLATE
• Optimize your images

• Make sprites with your images

• Combine CSS and JavaScript into one file for
  each

• Don't use "on the fly" compression plugins

• If you use a CSS and/or JavaScript compression
  plugin then make sure it stores it somehow
  instead of compressing on each load.
KEY POINTS FOR SPEEDING
   UP YOUR TEMPLATE
KEY POINTS FOR SPEEDING
     UP YOUR TEMPLATE



• Use a CDN for your template resources
KEY POINTS FOR SPEEDING
     UP YOUR TEMPLATE



• Use a CDN for your template resources

• If possible, remove calls in component or
  modules for library’s if they are already used so
  you don’t have them loading twice.
A FEW EXTENSIONS
     TO HELP
EXTENSIONS WE USE FOR
    DEVELOPMENT
EXTENSIONS WE USE FOR
       DEVELOPMENT


• Advanced Module Manager (www.nonumber.nl)
EXTENSIONS WE USE FOR
       DEVELOPMENT


• Advanced Module Manager (www.nonumber.nl)

• CSS3 Automated Generator (www.corephp.com)
EXTENSIONS WE USE FOR
       DEVELOPMENT


• Advanced Module Manager (www.nonumber.nl)

• CSS3 Automated Generator (www.corephp.com)

• JCE (www.joomlacontenteditor.net/)
EXTENSIONS WE USE FOR
       DEVELOPMENT


• Advanced Module Manager (www.nonumber.nl)

• CSS3 Automated Generator (www.corephp.com)

• JCE (www.joomlacontenteditor.net/)

• Mass Content (www.baticore.com)
Joomla! Day Chicago 2011 - Templating the right way - Jonathan Shroyer
Joomla! Day Chicago 2011 - Templating the right way - Jonathan Shroyer
Joomla! Day Chicago 2011 - Templating the right way - Jonathan Shroyer
ADVANCED MODULE
 MANAGER CODE
ADVANCED MODULE
       MANAGER CODE

How to assign to only articles:
ADVANCED MODULE
         MANAGER CODE

  How to assign to only articles:

• $view = 'article';
  /* --- DO NOT EDIT BELOW --- */
  if ( JRequest::getCmd( 'view' ) == $view ) {
        $pass = 1;
  } else {
       $pass = 0;
  }
  return $pass;
ADVANCED MODULE
 MANAGER CODE
ADVANCED MODULE
      MANAGER CODE


How to assign to Wordpress homepage:
ADVANCED MODULE
         MANAGER CODE


  How to assign to Wordpress homepage:

• if ( defined( 'ABSPATH' ) && is_home() ) {
       $pass = 1;
  } else {
       $pass = 0;
  }
  return $pass;
ADVANCED MODULE
 MANAGER CODE
ADVANCED MODULE
      MANAGER CODE


How to assign to Wordpress single blog:
ADVANCED MODULE
          MANAGER CODE


  How to assign to Wordpress single blog:

• if ( is_single() ) {
        $pass = 1;
  } else {
        $pass = 0;
  }
  return $pass;
AUTOMATED CSS3
  GENERATOR
AUTOMATED CSS3
         GENERATOR

Automatically creates many cross-browser CSS3
styles for you.
AUTOMATED CSS3
           GENERATOR

  Automatically creates many cross-browser CSS3
  styles for you.

• Dropshadow, Text Shadow, Rounded Corners,
  Opacity, Gradient, RGBA, Rotate, Border Image
AUTOMATED CSS3
            GENERATOR

  Automatically creates many cross-browser CSS3
  styles for you.

• Dropshadow, Text Shadow, Rounded Corners,
  Opacity, Gradient, RGBA, Rotate, Border Image

• Rounded Corner Example:
  .rounded {topleft_radius:8, topright_radius:8,
  bottomright_radius:8, bottomleft_radius:8,
  support_ie:yes};
Joomla! Day Chicago 2011 - Templating the right way - Jonathan Shroyer
MASS CONTENT
MASS CONTENT




Mass Content allows you to enter several
articles, categories, tags, etc. at once, including
assigning to menu item.
Joomla! Day Chicago 2011 - Templating the right way - Jonathan Shroyer
Q&A
“If we would have new
knowledge, we must get a
whole world of new
questions.”
           - Susanne K. Langer

More Related Content

Joomla! Day Chicago 2011 - Templating the right way - Jonathan Shroyer

  • 1. TEMPLATING THE RIGHT WAY by Jonathan Shroyer Twitter: @learncss Email: jonathan@corephp.com by Jonathan Shroyer
  • 4. DID YOU KNOW? Tables are for tabular data... not for layouts
  • 6. PROPER HEADINGS • H tags are possibly most important for SEOs
  • 7. PROPER HEADINGS • H tags are possibly most important for SEOs • One H1 per page
  • 8. PROPER HEADINGS • H tags are possibly most important for SEOs • One H1 per page • Opening page H1 should be company name and tagline/short description.
  • 9. PROPER HEADINGS • H tags are possibly most important for SEOs • One H1 per page • Opening page H1 should be company name and tagline/short description. • H1 tags on all inner pages should be article title.
  • 10. PROPER HEADINGS • H tags are possibly most important for SEOs • One H1 per page • Opening page H1 should be company name and tagline/short description. • H1 tags on all inner pages should be article title. • NEVER skip a tag! (ie. H2 to H4)
  • 11. LOGO CODE FOR YOUR TEMPLATE
  • 12. LOGO CODE FOR YOUR TEMPLATE if( JURI::current() == JURI::base() ) { ?> <h1 id="company-logo"> <a href="<?php echo JURI::base(); ?>"> Company Name </a> </h1>
  • 13. LOGO CODE FOR YOUR TEMPLATE
  • 14. LOGO CODE FOR YOUR TEMPLATE } else { <p id="company-logo"> <a href="<?php echo JURI::base(); ?>"> Company Name </a> </p> }
  • 15. HEADINGS INSIDE OF YOUR TEMPLATE
  • 16. HEADINGS INSIDE OF YOUR TEMPLATE • In your overrides you should use the same logic: if( JURI::current() == JURI::base() ) { $h = 2; } else { $h = 1; } <h<?php echo $h; ?>>Title</h<?php echo $h; ?>}
  • 17. HEADINGS INSIDE OF YOUR TEMPLATE • In your overrides you should use the same logic: if( JURI::current() == JURI::base() ) { $h = 2; } else { $h = 1; } <h<?php echo $h; ?>>Title</h<?php echo $h; ?>} • Module titles are virtually always H2
  • 19. IMAGES • Use alt tags on images which you want people to know what it is. (ie. If image wasn't there, would the description add to the content?)
  • 20. IMAGES • Use alt tags on images which you want people to know what it is. (ie. If image wasn't there, would the description add to the content?) • Learn how to size images properly and how to compress them. Extra size slows down site and can lower SEO value.
  • 22. WHAT ABOUT HTML5? • No SEO advantage at this time
  • 23. WHAT ABOUT HTML5? • No SEO advantage at this time • Personally don’t recommend it as support is less than HTML4.
  • 24. WHAT ABOUT HTML5? • No SEO advantage at this time • Personally don’t recommend it as support is less than HTML4. • Only use if you have a specific market that you know has the capability to properly display it.
  • 25. WHAT ABOUT HTML5? • No SEO advantage at this time • Personally don’t recommend it as support is less than HTML4. • Only use if you have a specific market that you know has the capability to properly display it. • It’s a great movement, but it’s really still the Wild Wild West.
  • 27. LEARN THE JOOMLA LANGUAGE
  • 28. LEARN THE JOOMLA LANGUAGE • Why should you learn the Joomla! library for template development?
  • 29. LEARN THE JOOMLA LANGUAGE • Why should you learn the Joomla! library for template development? • Allows you to do advanced logic with your template.
  • 30. LEARN THE JOOMLA LANGUAGE • Why should you learn the Joomla! library for template development? • Allows you to do advanced logic with your template. • Gives you options you never had before
  • 31. LEARN THE JOOMLA LANGUAGE
  • 32. LEARN THE JOOMLA LANGUAGE • JHTML
  • 33. LEARN THE JOOMLA LANGUAGE • JHTML • link, image, iframe, date, tooltip, calendar, etc.
  • 34. LEARN THE JOOMLA LANGUAGE • JHTML • link, image, iframe, date, tooltip, calendar, etc. • Example: $link = JHTML::_('image', 'images/stories/clock.jpg', null); echo $link;
  • 35. LEARN THE JOOMLA LANGUAGE • JHTML • link, image, iframe, date, tooltip, calendar, etc. • Example: $link = JHTML::_('image', 'images/stories/clock.jpg', null); echo $link; • http://api.joomla.org/__filesource/fsource_Joomla- Framework_HTML_joomlahtmlhtml.php.html#a191
  • 37. ADDING EXTERNAL CSS STYLESHEETS (JOOMLA 1.6+) • $doc = JFactory::getDocument(); $path = 'templates/' . $this->template . '/css/mystylesheet.css'; $doc->addStyleSheet( $path, , ‘text/css’, “screen, projection” );
  • 38. ADDING EXTERNAL CSS STYLESHEETS (JOOMLA 1.6+) • $doc = JFactory::getDocument(); $path = 'templates/' . $this->template . '/css/mystylesheet.css'; $doc->addStyleSheet( $path, , ‘text/css’, “screen, projection” ); • You can also use: JHTML::stylesheet( $path, array('media'=>'screen, projection' ) );
  • 39. ADDING CSS STYLES FOR ONLY IE
  • 40. ADDING CSS STYLES FOR ONLY IE $stylelink = '<!--[if lte IE 6]>' ."n"; $stylelink .= '<link rel="stylesheet" href="../css/IEonly.css" />' ."n"; $stylelink .= '<![endif]-->' ."n"; $doc =& JFactory::getDocument(); $doc->addCustomTag($stylelink);
  • 41. MAKE YOUR TEMPLATE UPGRADABLE In templateDetails.xml the opening is: <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE install PUBLIC "-//Joomla! 1.6// DTD template 1.0//EN" "http:// www.joomla.org/xml/dtd/1.6/template- install.dtd"> <extension version="1.7" type="template" client="site" method=”upgrade”>
  • 42. BUILDING BLOCKS USING CSS
  • 44. SIZE BOX grid_size boxes are used for width, height and overall positioning of box.
  • 45. SIZE BOX grid_size boxes are used for width, height and overall positioning of box.
  • 46. SIZE BOX grid_size boxes are used for width, height and overall positioning of box. .grid_size { width: 100%; height: auto; float: left; display: inline; position: relative; }
  • 47. SIZE BOX grid_size boxes are used for width, height and overall positioning of box. .grid_size { width: 100%; height: auto; float: left; display: inline; position: relative; }
  • 49. STYLE BOX grid_style boxes are used for padding, borders and positioning of content within box.
  • 50. STYLE BOX grid_style boxes are used for padding, borders and positioning of content within box.
  • 51. STYLE BOX grid_style boxes are used for padding, borders and positioning of content within box. .grid_style { width: auto; height: auto; display: block; top: 0; left: 0; clear: both; }
  • 52. STYLE BOX grid_style boxes are used for padding, borders and positioning of content within box. .grid_style { width: auto; height: auto; display: block; top: 0; left: 0; clear: both; }
  • 55. EXAMPLE BOX <div class=”grid_size”> <div class=”grid_style”>
  • 56. EXAMPLE BOX <div class=”grid_size”> <div class=”grid_style”> CSS Box
  • 57. EXAMPLE BOX <div class=”grid_size”> <div class=”grid_style”> CSS Box </div>
  • 58. EXAMPLE BOX <div class=”grid_size”> <div class=”grid_style”> CSS Box </div> </div>
  • 59. EXAMPLE BOX <div class=”grid_size”> <div class=”grid_style”> CSS Box </div> </div>
  • 61. ADD AS MANY VARIABLES AS POSSIBLE TO BODY TAG CLASS
  • 62. ADD AS MANY VARIABLES AS POSSIBLE TO BODY TAG CLASS <?php $body = ''; if( JRequest::getInt( 'Itemid' ) ) { $body .= 'itemid-'.JRequest::getInt( 'Itemid' ); } if( JRequest::getInt( 'id' ) ) { $body .= ' id-'.JRequest::getInt( 'id' ); } if( JRequest::getVar( 'task' ) ) { $body .= ' task-'.JRequest::getVar( 'task' ); }
  • 63. ADD AS MANY VARIABLES AS POSSIBLE TO BODY TAG CLASS
  • 64. ADD AS MANY VARIABLES AS POSSIBLE TO BODY TAG CLASS if( JRequest::getVar( 'view' ) ) { $body .= ' view-'.JRequest::getVar( 'view' ); } if( JRequest::getVar( 'layout' ) ) { $body .= ' layout-'.JRequest::getVar( 'layout' ); } if( JRequest::getVar( 'option' ) ) { $body .= ' option-'.JRequest::getVar( 'option' ); }
  • 65. ADD AS MANY VARIABLES AS POSSIBLE TO BODY TAG CLASS
  • 66. ADD AS MANY VARIABLES AS POSSIBLE TO BODY TAG CLASS $body .= ' lang-' . $this->language; $body .= ' direction-' . $this->direction; if( JURI::current() == JURI::base() ) { $body .= ' frontpage’; }
  • 68. global $mainframe; $menu = @$mainframe->getMenu(); $active = @$menu->getActive(); while ( $active->parent > 0 ) { $parent = $menu->getItem( $active->parent ); if ( 0 == $parent->parent ) { $top_level = $parent; break; } else { $active = $parent; } } $body .= ' menu_parent-' . $active->id;
  • 70. $user =& JFactory::getUser(); $userGroups = $user->groups; foreach($userGroups as $key => $value){ $replace = array(".", " "); $body .= ' group-' . strtolower( str_replace( $replace, '_', $key ) ); }
  • 72. HOW THE VARIABLES OUTPUT <body class=”<?php echo $body; ?>”> Outputs: <body class=”itemid-257 id-6 view-article option- com_content lang-en-gb direction-ltr frontpage menu_parent-1 group-super_users”>
  • 73. HOW WOULD YOU USE THE MENU_PARENT CODE?
  • 74. HOW WOULD YOU USE THE MENU_PARENT CODE? In the CSS you could use it to change the sidebar color for each parent menu and inherit into each child. .menu_parent-1 #sidebar { background: #ccc; } You can stack body classes safely: .view-article.menu_parent-1 #sidebar
  • 75. DOING DYNAMIC THE RIGHT WAY
  • 76. LOAD DYNAMIC CSS INTO THE HEAD
  • 77. LOAD DYNAMIC CSS INTO THE HEAD Don’t create external php css files. Instead do this...
  • 78. LOAD DYNAMIC CSS INTO THE HEAD Don’t create external php css files. Instead do this... $doc =& JFactory::getDocument(); $style = 'BODY {' . 'background: #00ff00;' . 'color: rgb(0,0,255);' . '}'; $doc->addStyleDeclaration( $style );
  • 79. A FEW NOTES ABOUT CREATING JOOMLA! 1.7+ TEMPLATES
  • 80. CREATING A NEW TEMPLATE
  • 81. CREATING A NEW TEMPLATE • Templates will not show up in Template Manager without being installed
  • 82. CREATING A NEW TEMPLATE • Templates will not show up in Template Manager without being installed • Clicking Discover in Extension Manager will make templates show in Templates tab in Template Manager, but not in Styles
  • 85. SETTING/REMOVING SCRIPTS Add this above your DOCTYPE
  • 86. SETTING/REMOVING SCRIPTS Add this above your DOCTYPE • JHtml::_('behavior.framework', false);
  • 87. SETTING/REMOVING SCRIPTS Add this above your DOCTYPE • JHtml::_('behavior.framework', false); • FALSE = just mootools core (89KB)
  • 88. SETTING/REMOVING SCRIPTS Add this above your DOCTYPE • JHtml::_('behavior.framework', false); • FALSE = just mootools core (89KB) • TRUE = mootools-core + mootools-more (89KB + 238KB = 327KB!)
  • 89. SETTING/REMOVING SCRIPTS Add this above your DOCTYPE • JHtml::_('behavior.framework', false); • FALSE = just mootools core (89KB) • TRUE = mootools-core + mootools-more (89KB + 238KB = 327KB!) To remove all scripts:
  • 90. SETTING/REMOVING SCRIPTS Add this above your DOCTYPE • JHtml::_('behavior.framework', false); • FALSE = just mootools core (89KB) • TRUE = mootools-core + mootools-more (89KB + 238KB = 327KB!) To remove all scripts: • $doc =& JFactory::getDocument(); $doc->_scripts = array();
  • 91. SETTING/REMOVING SCRIPTS Add this above your DOCTYPE • JHtml::_('behavior.framework', false); • FALSE = just mootools core (89KB) • TRUE = mootools-core + mootools-more (89KB + 238KB = 327KB!) To remove all scripts: • $doc =& JFactory::getDocument(); $doc->_scripts = array(); This is not recommended!
  • 93. REMOVING MOOTOOLS IN 1.7 $user =& JFactory::getUser(); if ( $user->get( 'guest' ) == 1 ) { $document =& JFactory::getDocument(); $headerstuff = $document->getHeadData(); reset($headerstuff['scripts']); foreach ($headerstuff['scripts'] as $key=>$value){ if (substr_count($key, 'mootools') > 0) unset($headerstuff['scripts'][$key]); } $document->setHeadData( $headerstuff ); }
  • 94. MAKE IT SMALLER... AND FASTER!
  • 95. KEY POINTS FOR SPEEDING UP YOUR TEMPLATE
  • 96. KEY POINTS FOR SPEEDING UP YOUR TEMPLATE • Optimize your images
  • 97. KEY POINTS FOR SPEEDING UP YOUR TEMPLATE • Optimize your images • Make sprites with your images
  • 98. KEY POINTS FOR SPEEDING UP YOUR TEMPLATE • Optimize your images • Make sprites with your images • Combine CSS and JavaScript into one file for each
  • 99. KEY POINTS FOR SPEEDING UP YOUR TEMPLATE • Optimize your images • Make sprites with your images • Combine CSS and JavaScript into one file for each • Don't use "on the fly" compression plugins
  • 100. KEY POINTS FOR SPEEDING UP YOUR TEMPLATE • Optimize your images • Make sprites with your images • Combine CSS and JavaScript into one file for each • Don't use "on the fly" compression plugins • If you use a CSS and/or JavaScript compression plugin then make sure it stores it somehow instead of compressing on each load.
  • 101. KEY POINTS FOR SPEEDING UP YOUR TEMPLATE
  • 102. KEY POINTS FOR SPEEDING UP YOUR TEMPLATE • Use a CDN for your template resources
  • 103. KEY POINTS FOR SPEEDING UP YOUR TEMPLATE • Use a CDN for your template resources • If possible, remove calls in component or modules for library’s if they are already used so you don’t have them loading twice.
  • 104. A FEW EXTENSIONS TO HELP
  • 105. EXTENSIONS WE USE FOR DEVELOPMENT
  • 106. EXTENSIONS WE USE FOR DEVELOPMENT • Advanced Module Manager (www.nonumber.nl)
  • 107. EXTENSIONS WE USE FOR DEVELOPMENT • Advanced Module Manager (www.nonumber.nl) • CSS3 Automated Generator (www.corephp.com)
  • 108. EXTENSIONS WE USE FOR DEVELOPMENT • Advanced Module Manager (www.nonumber.nl) • CSS3 Automated Generator (www.corephp.com) • JCE (www.joomlacontenteditor.net/)
  • 109. EXTENSIONS WE USE FOR DEVELOPMENT • Advanced Module Manager (www.nonumber.nl) • CSS3 Automated Generator (www.corephp.com) • JCE (www.joomlacontenteditor.net/) • Mass Content (www.baticore.com)
  • 114. ADVANCED MODULE MANAGER CODE How to assign to only articles:
  • 115. ADVANCED MODULE MANAGER CODE How to assign to only articles: • $view = 'article'; /* --- DO NOT EDIT BELOW --- */ if ( JRequest::getCmd( 'view' ) == $view ) { $pass = 1; } else { $pass = 0; } return $pass;
  • 117. ADVANCED MODULE MANAGER CODE How to assign to Wordpress homepage:
  • 118. ADVANCED MODULE MANAGER CODE How to assign to Wordpress homepage: • if ( defined( 'ABSPATH' ) && is_home() ) { $pass = 1; } else { $pass = 0; } return $pass;
  • 120. ADVANCED MODULE MANAGER CODE How to assign to Wordpress single blog:
  • 121. ADVANCED MODULE MANAGER CODE How to assign to Wordpress single blog: • if ( is_single() ) { $pass = 1; } else { $pass = 0; } return $pass;
  • 122. AUTOMATED CSS3 GENERATOR
  • 123. AUTOMATED CSS3 GENERATOR Automatically creates many cross-browser CSS3 styles for you.
  • 124. AUTOMATED CSS3 GENERATOR Automatically creates many cross-browser CSS3 styles for you. • Dropshadow, Text Shadow, Rounded Corners, Opacity, Gradient, RGBA, Rotate, Border Image
  • 125. AUTOMATED CSS3 GENERATOR Automatically creates many cross-browser CSS3 styles for you. • Dropshadow, Text Shadow, Rounded Corners, Opacity, Gradient, RGBA, Rotate, Border Image • Rounded Corner Example: .rounded {topleft_radius:8, topright_radius:8, bottomright_radius:8, bottomleft_radius:8, support_ie:yes};
  • 128. MASS CONTENT Mass Content allows you to enter several articles, categories, tags, etc. at once, including assigning to menu item.
  • 130. Q&A “If we would have new knowledge, we must get a whole world of new questions.” - Susanne K. Langer

Editor's Notes

  1. \n
  2. \n
  3. Style is the LAST thing you should think about when choosing tags. Base it on semantics.\n
  4. Style is the LAST thing you should think about when choosing tags. Base it on semantics.\nIf you want to style according to H tags then make classes called .H1, .H2, etc.\n
  5. Style is the LAST thing you should think about when choosing tags. Base it on semantics.\nIf you want to style according to H tags then make classes called .H1, .H2, etc.\n
  6. Style is the LAST thing you should think about when choosing tags. Base it on semantics.\nIf you want to style according to H tags then make classes called .H1, .H2, etc.\n
  7. Style is the LAST thing you should think about when choosing tags. Base it on semantics.\nIf you want to style according to H tags then make classes called .H1, .H2, etc.\n
  8. Style is the LAST thing you should think about when choosing tags. Base it on semantics.\nIf you want to style according to H tags then make classes called .H1, .H2, etc.\n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. Example: change module positions according to category, section or even inherit through to all child items in a menu.\n
  21. Example: change module positions according to category, section or even inherit through to all child items in a menu.\n
  22. Example: change module positions according to category, section or even inherit through to all child items in a menu.\n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. Here we are grabbing info from the menu to determine the parent item and inheriting through to all children. This was originally created for a library site that wanted unique colors for each menu area.\n
  51. Here we are grabbing info from the menu to determine the parent item and inheriting through to all children. This was originally created for a library site that wanted unique colors for each menu area.\n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n
  58. \n
  59. \n
  60. \n
  61. \n
  62. \n
  63. \n
  64. \n
  65. \n
  66. \n
  67. \n
  68. \n
  69. \n
  70. \n
  71. \n
  72. \n
  73. \n
  74. \n
  75. CDN: Content Delivery Network\n
  76. CDN: Content Delivery Network\n
  77. \n
  78. \n
  79. \n
  80. \n
  81. \n
  82. CDN: Content Delivery Network\n
  83. CDN: Content Delivery Network\n
  84. CDN: Content Delivery Network\n
  85. CDN: Content Delivery Network\n
  86. CDN: Content Delivery Network\n
  87. CDN: Content Delivery Network\n
  88. CDN: Content Delivery Network\n
  89. CDN: Content Delivery Network\n
  90. CDN: Content Delivery Network\n
  91. CDN: Content Delivery Network\n
  92. CDN: Content Delivery Network\n
  93. CDN: Content Delivery Network\n
  94. CDN: Content Delivery Network\n
  95. CDN: Content Delivery Network\n
  96. CDN: Content Delivery Network\n
  97. \n