SlideShare une entreprise Scribd logo
1  sur  10
Télécharger pour lire hors ligne
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

Contenu connexe

Tendances

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
 

Tendances (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
 

Similaire à 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
 

Similaire à 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
 

Plus 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
 

Plus 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
 

Dernier

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
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
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 Scriptwesley chun
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
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
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbuapidays
 
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
 
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
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
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
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
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.pdfsudhanshuwaghmare1
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
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 CVKhem
 
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
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
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
 

Dernier (20)

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
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
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
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
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
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
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
 
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
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
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...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
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
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
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 - 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...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 

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.