SlideShare uma empresa Scribd logo
1 de 31
Joomla! Day UK 2009
Joomla! Day UK 2009 Template Design Providing a flexible platform for digital publishing and collaboration. Chris Davenport Joomla! Core Team
Understanding templates Joomla has an incredibly powerful template system, yet surprisingly few template designers actually make use of this power.
Use a reset script ,[object Object],[object Object],[object Object],You can be clever and use the Joomla API: $reset = '/templates/' . $this->template . '/css/reset.css'; $this->addStylesheet( $this->baseurl . $reset );
Or use a CSS framework Examples: http://www.blueprintcss.org http://developer.yahoo.com/yui/grids/ http://elements.projectdesigns.org/ http://www.wymstyle.org/en/ http://www.yaml.de/en/ http://code.google.com/p/css-boilerplate/
Template execution Template execution is a two-phase process. Phase 1: All PHP code is executed. <?php ..... ?> Phase 2: All jdoc:include statements are replaced. <jdoc:include type=”...” /> See:  http://docs.joomla.org/How_are_templates_executed%3F
Template execution <?php if ($this->countModules( 'left' )) : ?> <div id=&quot;leftcolumn&quot;> <jdoc:include type=&quot;modules&quot; name=&quot;left&quot; style=&quot;rounded&quot; /> </div> <?php endif; ?> <div id=&quot;leftcolumn&quot;> <jdoc:include type=&quot;modules&quot; name=&quot;left&quot; style=&quot;rounded&quot; /> </div> Before execution After Phase 1 In phase 1 all the PHP code is executed In phase 2 all the jdoc:include statements are replaced
<div id=&quot;leftcolumn&quot;> <div class=&quot;module_menu&quot;> <div> <div> <div><h3>Main Menu</h3> <ul class=&quot;menu&quot;><li id=&quot;current&quot; class=&quot;active item1&quot;> ...... other HTML omitted ...... </div> </div> </div> </div> </div> Template execution After Phase 2
What does it mean? ,[object Object],[object Object],Example: <jdoc:include type=&quot;modules&quot; name=&quot;<?php echo $module_position; ?>&quot; /> More interesting example: <jdoc:include type=&quot;modules&quot; name=&quot;left&quot; style=”xhtml” attribs=”<?php echo $attribs; ?>” /> These attributes will be passed into the module chrome.
Module execution order ,[object Object],[object Object],[object Object]
Module chrome <jdoc:include type=&quot;modules&quot; name=&quot;left&quot; style=&quot;rounded&quot; /> <jdoc:include type=&quot;module&quot; name=&quot;mymenu&quot; style=&quot;rounded&quot; /> Applies to a module position Name of the module position Module chrome Applies to an individual module  Name of the module
Module chrome – xhtml <div class=&quot;rightcolumn&quot;> <div class=&quot;moduletable&quot;> <h3>Popular</h3> <ul class=&quot;mostread&quot;> <li class=&quot;mostread&quot;> .... other HTML omitted .... </div> </div> In black is the raw module output In red is the chrome “wrapper”
Module chrome – rounded <div id=&quot;left&quot;> <div class=&quot;module&quot;> <div> <div> <div><h3>Main Menu</h3> <ul class=&quot;menu&quot;><li id=&quot;current&quot; class=&quot;active item1&quot;> ...... other HTML omitted ...... </div> </div> </div> </div> </div> In black is the raw module output In red is the chrome “wrapper”
Module chrome
Module chrome
Module chrome / ** * Custom module chrome, echos the whole module in a <div> and the header in <h{x}>. The level of * the header can be configured through a 'headerLevel' attribute of the <jdoc:include /> tag. * Defaults to <h3> if none given */ function modChrome_beezDivision($module, &$params, &$attribs) { $headerLevel = isset($attribs['headerLevel']) ? (int) $attribs['headerLevel'] : 3; if (!empty ($module->content)) : ?> <div class=&quot;moduletable<?php echo $params->get('moduleclass_sfx'); ?>&quot;> <?php if ($module->showtitle) : ?> <h<?php echo $headerLevel; ?>><?php echo $module->title; ?></h<?php echo $headerLevel; ?>> <?php endif; ?> <?php echo $module->content; ?> </div> <?php endif; } Gets header level from headerLevel attribute Applies header level to header tag
Module chrome <jdoc:include type=”modules” name=”left” style=”beezDivision” /> In the Beez template index.php: But try: <jdoc:include type=”modules” name=”left” style=”beezDivision” headerLevel=”2” /> This will give exactly the same output as style=”xhtml” This will wrap the title in <h2> tags instead of <h3> tags. To use this in your template just copy [joomla-root]/templates/beez/html/modules.php to [joomla-root]/template/[your-template]/html/modules.php If you already have a modules.php file, then just copy-paste the modChrome_beezDivision function into it.
Module chrome
Cascading module chrome function modChrome_sliders( $module, &$params, &$attribs ) { jimport('joomla.html.pane'); if ($attribs['allowAllClose']  == 'false') $attribs['allowAllClose'] = false; if ($attribs['startTransition'] == 'false') $attribs['startTransition'] = false; $sliders = &JPane::getInstance( 'sliders', $attribs ); echo $sliders->startPanel( $module->title, 'module' . $module->id ); echo $module->content; echo $sliders->endPanel(); } <jdoc:include type=&quot;modules&quot; name=&quot;left&quot; style=&quot;sliders rounded&quot; /> Extra module chrome style added here
What can you access? JDocumentHTML Layout overrides have access to all variables in component and module views JSite JFactory The whole Framework API
Template parameters <?php if ($this->params->get( 'showComponent' )) : ?> <jdoc:include type=&quot;component&quot; /> <?php endif; ?> You can access the template parameters using $this->params->get( 'param-name' ); $this in a template is a JDocumentHTML object. http://docs.joomla.org/JDocumentHTML
Document properties ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Collapsing module positions <?php if ($this->countModules( 'user1 or user2' )) : ?> <div class=&quot;user1user2&quot;> <jdoc:include type=&quot;modules&quot; name=&quot;user1&quot; style=&quot;xhtml&quot; /> <jdoc:include type=&quot;modules&quot; name=&quot;user2&quot; style=&quot;xhtml&quot; /> </div> <?php endif; ?> Two module positions. Collapse only if neither module position has any modules enabled in it.
Collapsing module positions <?php if ($this->countModules( 'user1 or user2' )) : ?> <div class=&quot;user1user2&quot;> <jdoc:include type=&quot;modules&quot; name=&quot;user1&quot; style=&quot;xhtml&quot; /> <?php if ($this->countModules( 'user1 and user2' )) : ?> <div class=&quot;divider&quot;></div> <?php endif; ?> <jdoc:include type=&quot;modules&quot; name=&quot;user2&quot; style=&quot;xhtml&quot; /> </div> <?php endif; ?> Two module positions with a separator between them. Collapse only if neither module position has any modules enabled in it. But you only want the divider if both module positions have modules.
Using the application <?php $menu = & JSite::getMenu(); if ($menu->getActive() == $menu->getDefault()) { echo 'This is the front page'; } ?> How to determine if the user is viewing the front page <?php $menu = & JSite::getMenu(); if ($menu->getActive() == $menu->getDefault()) : ?> <div id=&quot;leftcolumn&quot;> <jdoc:include type=&quot;modules&quot; name=&quot;left&quot; style=&quot;rounded&quot; /> </div> <?php endif; ?>
Sections and categories $id = JRequest::getInt( 'id' ); $db =& JFactory::getDBO(); $query = 'SELECT cat.alias, sec.alias ' . 'FROM #__categories AS cat ' . 'LEFT JOIN #__content AS cont ON cat.id = cont.catid ' . 'LEFT JOIN #__sections AS sec ON sec.id = cont.sectionid ' . 'WHERE cont.id=' . (int)$id; $db->setQuery( $query ); $result = $db->loadRow(); if (is_array( $result )) { $cat = $result[0]; $sec = $result[1]; } <?php if ($sec == 'the-cms') : ?> <div id=&quot;thecms&quot;> <jdoc:include type=&quot;modules&quot; name=&quot;thecms&quot; /> </div> <?php endif; ?>
Framework API Always use JFactory where you can. $doc =& JFactory::getDocument(); Use  http://api.joomla.org and  http://docs.joomla.org/Framework
JFactory ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Other useful API classes ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Joomla template design Questions?
Copyright and Licence Copyright © 2009 Chris Davenport This presentation is available for use under the Joomla! Electronic Documentation License http://docs.joomla.org/JEDL

Mais conteúdo relacionado

Mais procurados

Optimizing Drupal for Mobile Devices
Optimizing Drupal for Mobile DevicesOptimizing Drupal for Mobile Devices
Optimizing Drupal for Mobile Devices
Sugree Phatanapherom
 
OSDC 2009 Rails Turtorial
OSDC 2009 Rails TurtorialOSDC 2009 Rails Turtorial
OSDC 2009 Rails Turtorial
Yi-Ting Cheng
 
Zepplin_Pronko_Magento_Festival Hall 1_Final
Zepplin_Pronko_Magento_Festival Hall 1_FinalZepplin_Pronko_Magento_Festival Hall 1_Final
Zepplin_Pronko_Magento_Festival Hall 1_Final
Max Pronko
 

Mais procurados (18)

WordPress development paradigms, idiosyncrasies and other big words
WordPress development paradigms, idiosyncrasies and other big wordsWordPress development paradigms, idiosyncrasies and other big words
WordPress development paradigms, idiosyncrasies and other big words
 
Optimizing Drupal for Mobile Devices
Optimizing Drupal for Mobile DevicesOptimizing Drupal for Mobile Devices
Optimizing Drupal for Mobile Devices
 
Introduction to Using PHP & MVC Frameworks
Introduction to Using PHP & MVC FrameworksIntroduction to Using PHP & MVC Frameworks
Introduction to Using PHP & MVC Frameworks
 
MVC in PHP
MVC in PHPMVC in PHP
MVC in PHP
 
GAEO
GAEOGAEO
GAEO
 
Intro to html5 Boilerplate
Intro to html5 BoilerplateIntro to html5 Boilerplate
Intro to html5 Boilerplate
 
Lecture 3 Javascript1
Lecture 3  Javascript1Lecture 3  Javascript1
Lecture 3 Javascript1
 
Gae
GaeGae
Gae
 
Building Complex GUI Apps The Right Way. With Ample SDK - SWDC2010
Building Complex GUI Apps The Right Way. With Ample SDK - SWDC2010Building Complex GUI Apps The Right Way. With Ample SDK - SWDC2010
Building Complex GUI Apps The Right Way. With Ample SDK - SWDC2010
 
Spring Surf 101
Spring Surf 101Spring Surf 101
Spring Surf 101
 
Facelets
FaceletsFacelets
Facelets
 
OSDC 2009 Rails Turtorial
OSDC 2009 Rails TurtorialOSDC 2009 Rails Turtorial
OSDC 2009 Rails Turtorial
 
Introduction To Django
Introduction To DjangoIntroduction To Django
Introduction To Django
 
Building Pluggable Web Applications using Django
Building Pluggable Web Applications using DjangoBuilding Pluggable Web Applications using Django
Building Pluggable Web Applications using Django
 
Deliverance: Plone theming without the learning curve from Plone Symposium Ea...
Deliverance: Plone theming without the learning curve from Plone Symposium Ea...Deliverance: Plone theming without the learning curve from Plone Symposium Ea...
Deliverance: Plone theming without the learning curve from Plone Symposium Ea...
 
Zepplin_Pronko_Magento_Festival Hall 1_Final
Zepplin_Pronko_Magento_Festival Hall 1_FinalZepplin_Pronko_Magento_Festival Hall 1_Final
Zepplin_Pronko_Magento_Festival Hall 1_Final
 
Processing XML with Java
Processing XML with JavaProcessing XML with Java
Processing XML with Java
 
The Structure of Web Code: A Case For Polymer, November 1, 2014
The Structure of Web Code: A Case For Polymer, November 1, 2014The Structure of Web Code: A Case For Polymer, November 1, 2014
The Structure of Web Code: A Case For Polymer, November 1, 2014
 

Destaque (6)

Joomla! Day UK 2009 Menus Presentation
Joomla! Day UK 2009 Menus PresentationJoomla! Day UK 2009 Menus Presentation
Joomla! Day UK 2009 Menus Presentation
 
Joomla! Day UK 2009 Basic Templates
Joomla! Day UK 2009 Basic TemplatesJoomla! Day UK 2009 Basic Templates
Joomla! Day UK 2009 Basic Templates
 
Agenda En
Agenda EnAgenda En
Agenda En
 
Joomla! Day UK 2009 Event Guide
Joomla! Day UK 2009 Event GuideJoomla! Day UK 2009 Event Guide
Joomla! Day UK 2009 Event Guide
 
Healthy eating sc
Healthy eating scHealthy eating sc
Healthy eating sc
 
英文 Rc heli
英文 Rc heli英文 Rc heli
英文 Rc heli
 

Semelhante a Joomla! Day UK 2009 Template Design

Система рендеринга в Magento
Система рендеринга в MagentoСистема рендеринга в Magento
Система рендеринга в Magento
Magecom Ukraine
 
Drupal 7 Theming - what's new
Drupal 7 Theming - what's newDrupal 7 Theming - what's new
Drupal 7 Theming - what's new
Marek Sotak
 
Debugging and Error handling
Debugging and Error handlingDebugging and Error handling
Debugging and Error handling
Suite Solutions
 
Intro To Mvc Development In Php
Intro To Mvc Development In PhpIntro To Mvc Development In Php
Intro To Mvc Development In Php
funkatron
 
Coder Presentation Szeged
Coder Presentation SzegedCoder Presentation Szeged
Coder Presentation Szeged
Doug Green
 
Widget Summit 2008
Widget Summit 2008Widget Summit 2008
Widget Summit 2008
Volkan Unsal
 
Zend - Installation And Sample Project Creation
Zend - Installation And Sample Project Creation Zend - Installation And Sample Project Creation
Zend - Installation And Sample Project Creation
Compare Infobase Limited
 

Semelhante a Joomla! Day UK 2009 Template Design (20)

Joomla Day UK 2009 Basic Templates
Joomla Day UK 2009 Basic TemplatesJoomla Day UK 2009 Basic Templates
Joomla Day UK 2009 Basic Templates
 
Create a web-app with Cgi Appplication
Create a web-app with Cgi AppplicationCreate a web-app with Cgi Appplication
Create a web-app with Cgi Appplication
 
WordPress Development Confoo 2010
WordPress Development Confoo 2010WordPress Development Confoo 2010
WordPress Development Confoo 2010
 
Система рендеринга в Magento
Система рендеринга в MagentoСистема рендеринга в Magento
Система рендеринга в Magento
 
Drupal 7 Theming - what's new
Drupal 7 Theming - what's newDrupal 7 Theming - what's new
Drupal 7 Theming - what's new
 
Debugging and Error handling
Debugging and Error handlingDebugging and Error handling
Debugging and Error handling
 
Practical catalyst
Practical catalystPractical catalyst
Practical catalyst
 
WordPress Standardized Loop API
WordPress Standardized Loop APIWordPress Standardized Loop API
WordPress Standardized Loop API
 
Intro To Mvc Development In Php
Intro To Mvc Development In PhpIntro To Mvc Development In Php
Intro To Mvc Development In Php
 
Coder Presentation Szeged
Coder Presentation SzegedCoder Presentation Szeged
Coder Presentation Szeged
 
Joomla! Template for Beginners
Joomla! Template for BeginnersJoomla! Template for Beginners
Joomla! Template for Beginners
 
Introduction to Zend Framework
Introduction to Zend FrameworkIntroduction to Zend Framework
Introduction to Zend Framework
 
Widget Summit 2008
Widget Summit 2008Widget Summit 2008
Widget Summit 2008
 
How to Develop Your First Ever Joomla Template?
How to Develop Your First Ever Joomla Template?How to Develop Your First Ever Joomla Template?
How to Develop Your First Ever Joomla Template?
 
Drupal Best Practices
Drupal Best PracticesDrupal Best Practices
Drupal Best Practices
 
Finding Your Way: Understanding Magento Code
Finding Your Way: Understanding Magento CodeFinding Your Way: Understanding Magento Code
Finding Your Way: Understanding Magento Code
 
Django Rest Framework and React and Redux, Oh My!
Django Rest Framework and React and Redux, Oh My!Django Rest Framework and React and Redux, Oh My!
Django Rest Framework and React and Redux, Oh My!
 
ActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group PresentationActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group Presentation
 
Zend - Installation And Sample Project Creation
Zend - Installation And Sample Project Creation Zend - Installation And Sample Project Creation
Zend - Installation And Sample Project Creation
 
Css, xhtml, javascript
Css, xhtml, javascriptCss, xhtml, javascript
Css, xhtml, javascript
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Último (20)

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
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...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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...
 
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...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 

Joomla! Day UK 2009 Template Design

  • 2. Joomla! Day UK 2009 Template Design Providing a flexible platform for digital publishing and collaboration. Chris Davenport Joomla! Core Team
  • 3. Understanding templates Joomla has an incredibly powerful template system, yet surprisingly few template designers actually make use of this power.
  • 4.
  • 5. Or use a CSS framework Examples: http://www.blueprintcss.org http://developer.yahoo.com/yui/grids/ http://elements.projectdesigns.org/ http://www.wymstyle.org/en/ http://www.yaml.de/en/ http://code.google.com/p/css-boilerplate/
  • 6. Template execution Template execution is a two-phase process. Phase 1: All PHP code is executed. <?php ..... ?> Phase 2: All jdoc:include statements are replaced. <jdoc:include type=”...” /> See: http://docs.joomla.org/How_are_templates_executed%3F
  • 7. Template execution <?php if ($this->countModules( 'left' )) : ?> <div id=&quot;leftcolumn&quot;> <jdoc:include type=&quot;modules&quot; name=&quot;left&quot; style=&quot;rounded&quot; /> </div> <?php endif; ?> <div id=&quot;leftcolumn&quot;> <jdoc:include type=&quot;modules&quot; name=&quot;left&quot; style=&quot;rounded&quot; /> </div> Before execution After Phase 1 In phase 1 all the PHP code is executed In phase 2 all the jdoc:include statements are replaced
  • 8. <div id=&quot;leftcolumn&quot;> <div class=&quot;module_menu&quot;> <div> <div> <div><h3>Main Menu</h3> <ul class=&quot;menu&quot;><li id=&quot;current&quot; class=&quot;active item1&quot;> ...... other HTML omitted ...... </div> </div> </div> </div> </div> Template execution After Phase 2
  • 9.
  • 10.
  • 11. Module chrome <jdoc:include type=&quot;modules&quot; name=&quot;left&quot; style=&quot;rounded&quot; /> <jdoc:include type=&quot;module&quot; name=&quot;mymenu&quot; style=&quot;rounded&quot; /> Applies to a module position Name of the module position Module chrome Applies to an individual module Name of the module
  • 12. Module chrome – xhtml <div class=&quot;rightcolumn&quot;> <div class=&quot;moduletable&quot;> <h3>Popular</h3> <ul class=&quot;mostread&quot;> <li class=&quot;mostread&quot;> .... other HTML omitted .... </div> </div> In black is the raw module output In red is the chrome “wrapper”
  • 13. Module chrome – rounded <div id=&quot;left&quot;> <div class=&quot;module&quot;> <div> <div> <div><h3>Main Menu</h3> <ul class=&quot;menu&quot;><li id=&quot;current&quot; class=&quot;active item1&quot;> ...... other HTML omitted ...... </div> </div> </div> </div> </div> In black is the raw module output In red is the chrome “wrapper”
  • 16. Module chrome / ** * Custom module chrome, echos the whole module in a <div> and the header in <h{x}>. The level of * the header can be configured through a 'headerLevel' attribute of the <jdoc:include /> tag. * Defaults to <h3> if none given */ function modChrome_beezDivision($module, &$params, &$attribs) { $headerLevel = isset($attribs['headerLevel']) ? (int) $attribs['headerLevel'] : 3; if (!empty ($module->content)) : ?> <div class=&quot;moduletable<?php echo $params->get('moduleclass_sfx'); ?>&quot;> <?php if ($module->showtitle) : ?> <h<?php echo $headerLevel; ?>><?php echo $module->title; ?></h<?php echo $headerLevel; ?>> <?php endif; ?> <?php echo $module->content; ?> </div> <?php endif; } Gets header level from headerLevel attribute Applies header level to header tag
  • 17. Module chrome <jdoc:include type=”modules” name=”left” style=”beezDivision” /> In the Beez template index.php: But try: <jdoc:include type=”modules” name=”left” style=”beezDivision” headerLevel=”2” /> This will give exactly the same output as style=”xhtml” This will wrap the title in <h2> tags instead of <h3> tags. To use this in your template just copy [joomla-root]/templates/beez/html/modules.php to [joomla-root]/template/[your-template]/html/modules.php If you already have a modules.php file, then just copy-paste the modChrome_beezDivision function into it.
  • 19. Cascading module chrome function modChrome_sliders( $module, &$params, &$attribs ) { jimport('joomla.html.pane'); if ($attribs['allowAllClose'] == 'false') $attribs['allowAllClose'] = false; if ($attribs['startTransition'] == 'false') $attribs['startTransition'] = false; $sliders = &JPane::getInstance( 'sliders', $attribs ); echo $sliders->startPanel( $module->title, 'module' . $module->id ); echo $module->content; echo $sliders->endPanel(); } <jdoc:include type=&quot;modules&quot; name=&quot;left&quot; style=&quot;sliders rounded&quot; /> Extra module chrome style added here
  • 20. What can you access? JDocumentHTML Layout overrides have access to all variables in component and module views JSite JFactory The whole Framework API
  • 21. Template parameters <?php if ($this->params->get( 'showComponent' )) : ?> <jdoc:include type=&quot;component&quot; /> <?php endif; ?> You can access the template parameters using $this->params->get( 'param-name' ); $this in a template is a JDocumentHTML object. http://docs.joomla.org/JDocumentHTML
  • 22.
  • 23. Collapsing module positions <?php if ($this->countModules( 'user1 or user2' )) : ?> <div class=&quot;user1user2&quot;> <jdoc:include type=&quot;modules&quot; name=&quot;user1&quot; style=&quot;xhtml&quot; /> <jdoc:include type=&quot;modules&quot; name=&quot;user2&quot; style=&quot;xhtml&quot; /> </div> <?php endif; ?> Two module positions. Collapse only if neither module position has any modules enabled in it.
  • 24. Collapsing module positions <?php if ($this->countModules( 'user1 or user2' )) : ?> <div class=&quot;user1user2&quot;> <jdoc:include type=&quot;modules&quot; name=&quot;user1&quot; style=&quot;xhtml&quot; /> <?php if ($this->countModules( 'user1 and user2' )) : ?> <div class=&quot;divider&quot;></div> <?php endif; ?> <jdoc:include type=&quot;modules&quot; name=&quot;user2&quot; style=&quot;xhtml&quot; /> </div> <?php endif; ?> Two module positions with a separator between them. Collapse only if neither module position has any modules enabled in it. But you only want the divider if both module positions have modules.
  • 25. Using the application <?php $menu = & JSite::getMenu(); if ($menu->getActive() == $menu->getDefault()) { echo 'This is the front page'; } ?> How to determine if the user is viewing the front page <?php $menu = & JSite::getMenu(); if ($menu->getActive() == $menu->getDefault()) : ?> <div id=&quot;leftcolumn&quot;> <jdoc:include type=&quot;modules&quot; name=&quot;left&quot; style=&quot;rounded&quot; /> </div> <?php endif; ?>
  • 26. Sections and categories $id = JRequest::getInt( 'id' ); $db =& JFactory::getDBO(); $query = 'SELECT cat.alias, sec.alias ' . 'FROM #__categories AS cat ' . 'LEFT JOIN #__content AS cont ON cat.id = cont.catid ' . 'LEFT JOIN #__sections AS sec ON sec.id = cont.sectionid ' . 'WHERE cont.id=' . (int)$id; $db->setQuery( $query ); $result = $db->loadRow(); if (is_array( $result )) { $cat = $result[0]; $sec = $result[1]; } <?php if ($sec == 'the-cms') : ?> <div id=&quot;thecms&quot;> <jdoc:include type=&quot;modules&quot; name=&quot;thecms&quot; /> </div> <?php endif; ?>
  • 27. Framework API Always use JFactory where you can. $doc =& JFactory::getDocument(); Use http://api.joomla.org and http://docs.joomla.org/Framework
  • 28.
  • 29.
  • 31. Copyright and Licence Copyright © 2009 Chris Davenport This presentation is available for use under the Joomla! Electronic Documentation License http://docs.joomla.org/JEDL