SlideShare uma empresa Scribd logo
1 de 10
Baixar para ler offline
Drupal Advanced Theming
  DrupalCamp Estonia



      Kaido Toomingas
       14.June 2012
Problem
●   You need more than Drupal theme can offer you out of box
●   You dont need some stuff wich Drupal offers You out of box
Solutions
●   Lets just put this into templates ;) What does Your designer would
    say?
●   What should I do then?
●   Template.php
●   Custom module
How can I implement this?
●   Hooks? Examples...?
●   TEMPLATE_preprocess(&$variables, $hook)
●   HOOK_form_alter(&$form, &$form_state, $form_id)
●   theme($hook, $variables = array())
●   THEMEHOOK_settings() in theme-settings.php
●   THEMENAME_form_system_theme_settings_alter(&$form,
    $form_state)
●   hook_theme_registry_alter()
Hooks

Hooks in drupal are functions
wich will help you to change or
extend default functionality.
Preprocess
●       TEMPLATE_preprocess(&$variables, $hook)
●       TEMPLATE_preprocess_HOOK(&$variables)
●   Manipulate or create variables. Example page variables. You
    can add these into template.php.
    Example:
    function template_preprocess_foo(&$variables) {
        $variables['foo_list'] = array(
         'list item 1',
         'list item 2',
         'list item 3',
        );
    }
Modify forms
●       HOOK_form_alter(&$form, &$form_state, $form_id)
●       hook_form_FORM_ID_alter
    ●   Change existing form elements by changing or adding
        some arrays.
    ●   Create new form elements – There is better way.

Example:

function example_form_alter(&$form, &$form_state, $form_id) {
  dsm($form_id); // print form ID to messages You need devel
module switched for using dsm() function
  dsm($form); // pretty print array using Krumo to messages
}
Theme some data
●   theme($hook, $variables = array())
●   Usecase: You want to create a table, image or some other element
    from you data. You should use theme function for that.
●   Usage: Can be used in template.php or custom modules.
    Example:

    theme('table', array(
      'header' => $header,
      'rows' => $options,
      'attributes' => array('class' => array('mytable'))
    ));
hook_theme_registry_alter()
●   This is the most powerful themer helper wich should be used only
    when can't find any way to change your theme.
●   You can use this when there is module wich doesnt have proper theme
    fuctions wich could be overwritten.
Advanced theming

Mais conteúdo relacionado

Mais procurados

Mikhail Kraynuk. Form api. Drupal 8
Mikhail Kraynuk. Form api. Drupal 8Mikhail Kraynuk. Form api. Drupal 8
Mikhail Kraynuk. Form api. Drupal 8i20 Group
 
AngulrJS Overview
AngulrJS OverviewAngulrJS Overview
AngulrJS OverviewEyal Vardi
 
那些年,我用 Django Admin 接的案子
那些年,我用 Django Admin 接的案子那些年,我用 Django Admin 接的案子
那些年,我用 Django Admin 接的案子flywindy
 
WordPress REST API: Expert Advice & Practical Use Cases
WordPress REST API: Expert Advice & Practical Use CasesWordPress REST API: Expert Advice & Practical Use Cases
WordPress REST API: Expert Advice & Practical Use CasesPantheon
 
Drupal Theming
Drupal ThemingDrupal Theming
Drupal Themingtakrin54
 
Drupal sins 2016 10-06
Drupal sins 2016 10-06Drupal sins 2016 10-06
Drupal sins 2016 10-06Aaron Crosman
 
10 useful WordPress functions (and maybe more)
10 useful WordPress functions (and maybe more)10 useful WordPress functions (and maybe more)
10 useful WordPress functions (and maybe more)Giustino Borzacchiello
 
Advanced Drupal Views: Theming your View
Advanced Drupal Views: Theming your ViewAdvanced Drupal Views: Theming your View
Advanced Drupal Views: Theming your ViewRyan Cross
 
DBIC 2 - Resultsets
DBIC 2 - ResultsetsDBIC 2 - Resultsets
DBIC 2 - ResultsetsAran Deltac
 

Mais procurados (11)

Js c1 best practices
Js c1 best practicesJs c1 best practices
Js c1 best practices
 
Mikhail Kraynuk. Form api. Drupal 8
Mikhail Kraynuk. Form api. Drupal 8Mikhail Kraynuk. Form api. Drupal 8
Mikhail Kraynuk. Form api. Drupal 8
 
AngulrJS Overview
AngulrJS OverviewAngulrJS Overview
AngulrJS Overview
 
那些年,我用 Django Admin 接的案子
那些年,我用 Django Admin 接的案子那些年,我用 Django Admin 接的案子
那些年,我用 Django Admin 接的案子
 
WordPress REST API: Expert Advice & Practical Use Cases
WordPress REST API: Expert Advice & Practical Use CasesWordPress REST API: Expert Advice & Practical Use Cases
WordPress REST API: Expert Advice & Practical Use Cases
 
Drupal Theming
Drupal ThemingDrupal Theming
Drupal Theming
 
Drupal sins 2016 10-06
Drupal sins 2016 10-06Drupal sins 2016 10-06
Drupal sins 2016 10-06
 
10 useful WordPress functions (and maybe more)
10 useful WordPress functions (and maybe more)10 useful WordPress functions (and maybe more)
10 useful WordPress functions (and maybe more)
 
Advanced Drupal Views: Theming your View
Advanced Drupal Views: Theming your ViewAdvanced Drupal Views: Theming your View
Advanced Drupal Views: Theming your View
 
DBIC 2 - Resultsets
DBIC 2 - ResultsetsDBIC 2 - Resultsets
DBIC 2 - Resultsets
 
Table through php
Table through phpTable through php
Table through php
 

Semelhante a Advanced theming

D7 theming what's new - London
D7 theming what's new - LondonD7 theming what's new - London
D7 theming what's new - LondonMarek Sotak
 
Drupal Module Development - OSI Days 2010
Drupal Module Development - OSI Days 2010Drupal Module Development - OSI Days 2010
Drupal Module Development - OSI Days 2010Siva Epari
 
Drupal Module Development
Drupal Module DevelopmentDrupal Module Development
Drupal Module Developmentipsitamishra
 
Drupal 8: Theming
Drupal 8: ThemingDrupal 8: Theming
Drupal 8: Themingdrubb
 
Clean code and refactoring
Clean code and refactoringClean code and refactoring
Clean code and refactoringYuriy Gerasimov
 
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
 
Improve theming with (Twitter) Bootstrap
Improve theming with  (Twitter) BootstrapImprove theming with  (Twitter) Bootstrap
Improve theming with (Twitter) BootstrapAndrey Yurtaev
 
Drupal 7 Theming - Behind the scenes
Drupal 7 Theming - Behind the scenes Drupal 7 Theming - Behind the scenes
Drupal 7 Theming - Behind the scenes ramakesavan
 
Atomicant Drupal 6 Theming
Atomicant Drupal 6 ThemingAtomicant Drupal 6 Theming
Atomicant Drupal 6 ThemingMarek Sotak
 
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 plugin #3
WordPress plugin #3WordPress plugin #3
WordPress plugin #3giwoolee
 
Drupal 7 Theming - what's new
Drupal 7 Theming - what's newDrupal 7 Theming - what's new
Drupal 7 Theming - what's newMarek Sotak
 
Drupal vs WordPress
Drupal vs WordPressDrupal vs WordPress
Drupal vs WordPressWalter Ebert
 
Views Style Plugins
Views Style PluginsViews Style Plugins
Views Style Pluginsmwrather
 
Learning the basics of the Drupal API
Learning the basics of the Drupal APILearning the basics of the Drupal API
Learning the basics of the Drupal APIAlexandru Badiu
 

Semelhante a Advanced theming (20)

D7 theming what's new - London
D7 theming what's new - LondonD7 theming what's new - London
D7 theming what's new - London
 
Drupal Module Development - OSI Days 2010
Drupal Module Development - OSI Days 2010Drupal Module Development - OSI Days 2010
Drupal Module Development - OSI Days 2010
 
Drupal Module Development
Drupal Module DevelopmentDrupal Module Development
Drupal Module Development
 
Drupal 8: Theming
Drupal 8: ThemingDrupal 8: Theming
Drupal 8: Theming
 
Clean code and refactoring
Clean code and refactoringClean code and refactoring
Clean code and refactoring
 
Fapi
FapiFapi
Fapi
 
Drupal Front End PHP
Drupal Front End PHPDrupal Front End PHP
Drupal Front End PHP
 
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
 
Improve theming with (Twitter) Bootstrap
Improve theming with  (Twitter) BootstrapImprove theming with  (Twitter) Bootstrap
Improve theming with (Twitter) Bootstrap
 
Django design-patterns
Django design-patternsDjango design-patterns
Django design-patterns
 
Design Patterns and Usage
Design Patterns and UsageDesign Patterns and Usage
Design Patterns and Usage
 
Drupal 7 Theming - Behind the scenes
Drupal 7 Theming - Behind the scenes Drupal 7 Theming - Behind the scenes
Drupal 7 Theming - Behind the scenes
 
Atomicant Drupal 6 Theming
Atomicant Drupal 6 ThemingAtomicant Drupal 6 Theming
Atomicant Drupal 6 Theming
 
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 plugin #3
WordPress plugin #3WordPress plugin #3
WordPress plugin #3
 
Drupal 7 Theming - what's new
Drupal 7 Theming - what's newDrupal 7 Theming - what's new
Drupal 7 Theming - what's new
 
Drupal vs WordPress
Drupal vs WordPressDrupal vs WordPress
Drupal vs WordPress
 
Views Style Plugins
Views Style PluginsViews Style Plugins
Views Style Plugins
 
Learning the basics of the Drupal API
Learning the basics of the Drupal APILearning the basics of the Drupal API
Learning the basics of the Drupal API
 
Drupal Render API
Drupal Render APIDrupal Render API
Drupal Render API
 

Mais de drupalcampest

Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS drupalcampest
 
Welcome to Drupalcamp Estonia 2012
Welcome to Drupalcamp Estonia 2012Welcome to Drupalcamp Estonia 2012
Welcome to Drupalcamp Estonia 2012drupalcampest
 
Implementing Drupalcamp sites
Implementing Drupalcamp sitesImplementing Drupalcamp sites
Implementing Drupalcamp sitesdrupalcampest
 
Designing Drupalcamp sites
Designing Drupalcamp sitesDesigning Drupalcamp sites
Designing Drupalcamp sitesdrupalcampest
 
Drupal vs. the Others
Drupal vs. the OthersDrupal vs. the Others
Drupal vs. the Othersdrupalcampest
 
Migrating University of Tartu websites to Drupal
Migrating University of Tartu websites to DrupalMigrating University of Tartu websites to Drupal
Migrating University of Tartu websites to Drupaldrupalcampest
 
Drupalcamp Tallinn - Drupal 8
Drupalcamp Tallinn - Drupal 8Drupalcamp Tallinn - Drupal 8
Drupalcamp Tallinn - Drupal 8drupalcampest
 
Drupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance SitesDrupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance Sitesdrupalcampest
 
Drupalcamp Estonia - Drupal 7
Drupalcamp Estonia - Drupal 7Drupalcamp Estonia - Drupal 7
Drupalcamp Estonia - Drupal 7drupalcampest
 
Drupalcamp Estonia - Introduction to Drupal
Drupalcamp Estonia - Introduction to DrupalDrupalcamp Estonia - Introduction to Drupal
Drupalcamp Estonia - Introduction to Drupaldrupalcampest
 
Drupalcamp Estonia 2011 - Welcome
Drupalcamp Estonia 2011 - WelcomeDrupalcamp Estonia 2011 - Welcome
Drupalcamp Estonia 2011 - Welcomedrupalcampest
 

Mais de drupalcampest (11)

Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS
 
Welcome to Drupalcamp Estonia 2012
Welcome to Drupalcamp Estonia 2012Welcome to Drupalcamp Estonia 2012
Welcome to Drupalcamp Estonia 2012
 
Implementing Drupalcamp sites
Implementing Drupalcamp sitesImplementing Drupalcamp sites
Implementing Drupalcamp sites
 
Designing Drupalcamp sites
Designing Drupalcamp sitesDesigning Drupalcamp sites
Designing Drupalcamp sites
 
Drupal vs. the Others
Drupal vs. the OthersDrupal vs. the Others
Drupal vs. the Others
 
Migrating University of Tartu websites to Drupal
Migrating University of Tartu websites to DrupalMigrating University of Tartu websites to Drupal
Migrating University of Tartu websites to Drupal
 
Drupalcamp Tallinn - Drupal 8
Drupalcamp Tallinn - Drupal 8Drupalcamp Tallinn - Drupal 8
Drupalcamp Tallinn - Drupal 8
 
Drupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance SitesDrupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance Sites
 
Drupalcamp Estonia - Drupal 7
Drupalcamp Estonia - Drupal 7Drupalcamp Estonia - Drupal 7
Drupalcamp Estonia - Drupal 7
 
Drupalcamp Estonia - Introduction to Drupal
Drupalcamp Estonia - Introduction to DrupalDrupalcamp Estonia - Introduction to Drupal
Drupalcamp Estonia - Introduction to Drupal
 
Drupalcamp Estonia 2011 - Welcome
Drupalcamp Estonia 2011 - WelcomeDrupalcamp Estonia 2011 - Welcome
Drupalcamp Estonia 2011 - Welcome
 

Último

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 educationjfdjdjcjdnsjd
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 
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
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
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)wesley chun
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
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 TerraformAndrey Devyatkin
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
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
 

Último (20)

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
 
+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...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
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
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
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)
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
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
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
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...
 

Advanced theming

  • 1. Drupal Advanced Theming DrupalCamp Estonia Kaido Toomingas 14.June 2012
  • 2. Problem ● You need more than Drupal theme can offer you out of box ● You dont need some stuff wich Drupal offers You out of box
  • 3. Solutions ● Lets just put this into templates ;) What does Your designer would say? ● What should I do then? ● Template.php ● Custom module
  • 4. How can I implement this? ● Hooks? Examples...? ● TEMPLATE_preprocess(&$variables, $hook) ● HOOK_form_alter(&$form, &$form_state, $form_id) ● theme($hook, $variables = array()) ● THEMEHOOK_settings() in theme-settings.php ● THEMENAME_form_system_theme_settings_alter(&$form, $form_state) ● hook_theme_registry_alter()
  • 5. Hooks Hooks in drupal are functions wich will help you to change or extend default functionality.
  • 6. Preprocess ● TEMPLATE_preprocess(&$variables, $hook) ● TEMPLATE_preprocess_HOOK(&$variables) ● Manipulate or create variables. Example page variables. You can add these into template.php. Example: function template_preprocess_foo(&$variables) { $variables['foo_list'] = array( 'list item 1', 'list item 2', 'list item 3', ); }
  • 7. Modify forms ● HOOK_form_alter(&$form, &$form_state, $form_id) ● hook_form_FORM_ID_alter ● Change existing form elements by changing or adding some arrays. ● Create new form elements – There is better way. Example: function example_form_alter(&$form, &$form_state, $form_id) { dsm($form_id); // print form ID to messages You need devel module switched for using dsm() function dsm($form); // pretty print array using Krumo to messages }
  • 8. Theme some data ● theme($hook, $variables = array()) ● Usecase: You want to create a table, image or some other element from you data. You should use theme function for that. ● Usage: Can be used in template.php or custom modules. Example: theme('table', array( 'header' => $header, 'rows' => $options, 'attributes' => array('class' => array('mytable')) ));
  • 9. hook_theme_registry_alter() ● This is the most powerful themer helper wich should be used only when can't find any way to change your theme. ● You can use this when there is module wich doesnt have proper theme fuctions wich could be overwritten.