SlideShare une entreprise Scribd logo
1  sur  19
Télécharger pour lire hors ligne
hook


                              HOOK



   Ramu Ramakesavan
  Phoenix Drupal User Group
         January 2012
Client Side             Server Side
HTML                    Apache Webserver

CSS Style Sheets        PHP, Perl

JavaScripts             MySQL
                        Drupal Framework
AJAX
                          Themes, Regions, Blocks
                          Forms, Views, Panels
         Drupal           Administration
       Installation       Module, Hooks
    Updates/ Upgrades     Caching
        Crawlers
                          Debug
•   Display of data on the webpage
    •   Structured presentation
    •   Site specific modifications to presentation


•   Creation of data for the webpage
    •   Drupal7 mechanism for data creation
    •   flow of control during data creation (PHP code)
    •   Site specific modifications to data creation
    •   Searchable and editable data format
themes/bartik/bartik.info
                            Option „Demo block regions‟ under
                            structure/block in adminstration
•modules/system/page.tpl.php
•themes/bartik/templates/page.tpl.php




                                        •modules/system/html.tpl.php
•   template_preprocess; template_preprocess_<theme_element>
    •   (web/includes/theme.inc)
    •   default variables for all theme element/ specific theme elements
    •   theme_element: page, html, block, region, maintenance_page

•   <mymod>_preprocess; <mymod>_preprocess_<theme_element>
    •   (web/sites/all/modules/<mymod>)
    •   modules that didn't define the theme hook can alter the variables.

•   <ENGINE>_engine_preprocess;<ENGINE>_engine_preprocess_<them
    e_element>
    •   (web/themes/engines/phptemplate/phptemple.engine)
    •   Drupal uses PHPTemplate as default engine

•   <THEME>_preprocess; <THEME>_preprocess_ <theme_element>
    •   (web/sites/all/theme/template.php)
    •   Theme Bartik can set variables
•   template_process; template_process_<theme_element>
    •   (web/includes/theme.inc)
    •   default variables for all theme element/ specific theme elements
    •   theme_element: page, html, block, region, maintenance_page

•   <mymod>_process; <mymod>_process_<theme_element>
    •   (web/sites/all/modules/<mymod>)
    •   modules that didn't define the theme hook can alter the variables.

•   <ENGINE>_engine_process;<ENGINE>_engine_process_<theme_ele
    ment>
    •   (web/themes/engines/phptemplate/phptemple.engine)
    •   Drupal uses PHPTemplate as default engine

•   <THEME>_process; <THEME>_process_ <theme_element>
    •   (web/sites/all/theme/template.php)
    •   Theme Bartik can set variables
   If implemented using a real function instead of page.tpl.php then only
    XXXX_preprocess_<theme_element>
    XXXX_process_<theme_element>
    routines are executed

   Pre_process/process functions can define theme_hook_suggestion and
                            s
    theme_hook_suggestion that can override current theme
    implementation

   links_contextual_node defines fallback implementations for named
    objects / contexts
       Function   a_b_c
       Function   a_b
       Function   a



Question: When should these capabilities be used?
•   Display of data on the webpage
    •   Structured presentation
    •   Site specific modifications to presentation


•   Creation of data for the webpage
    •   Drupal7 mechanism for data creation
    •   flow of control during data creation (PHP code)
    •   Site specific modifications to data creation
    •   Searchable and editable data format
   A web-page is created when a
    http://www.ramustores.com/?q=examples/theming_example
    is entered at the URL box in a browser

   A web-page is updated when a Menu item that is
    assigned
    http://www.ramustores.com/?q=examples/theming_example
    is selected

   Modules register path-CBfunction mapping that
    are stored in menu_router table
         Simplified URL works on top of this?
function <mymodule>_menu() {
    $items['examples/theming_example'] =
    array(
        'title' => 'Theming Example',
        'description' => 'Some theming examples.',
        'page callback' => 'theming_example_page',
        'access callback' => TRUE,
        'access arguments' => array('access content'),
    );
    $items['examples/theming_example/theming_example_list_page'] =
    array(
        'title' => 'Theming a list',
        'page callback' => 'theming_example_list_page',
        'access arguments' => array('access content'),
        'weight' => 1,
    );
    return $items;
}
function theming_example_page() {
     $content[0] = t('Some examples of pages and forms that are run
       through theme functions.');
     $content[1] = l(t('Simple page with a list'),
       'examples/theming_example/theming_example_list_page');
     $content[2] = l(t('Simple form 1'),
       'examples/theming_example/theming_example_order_form');
     $content[3] = l(t('Simple form 2'),
       'examples/theming_example/theming_example_text_form');
     $content['#theme_wrappers'] =
       array('theming_example_content_array');
     return $content;
}
1,    User enters URL
      _http://localhost/web/?q=examples/theming_example

2.     Drupal executes code in web/index.php
        invokes function menu_execute_active_handler

3.     menu_execute_active_handler (menu.inc) does the following
        searches menu_router for (examples/theming_example) and gets
         corresponding CallBackFunction.
        MainContent=CBfunction(“examples/theming_example”)
        drupal_deliver_page(MainContent, HTML (not AJAX or XML))
         defined in menu.inc

4.     Drupal_deliver_page (common.inc) does the following:
        drupal_deliver_html_page (MainContent)

5.     Drupal_deliver_html_page (common.inc) does the following:
        drupal_render_page(MainContent)
1.      drupal_render_page($MainContent) (common.inc) does the following:
     1.    Copies the $MainContent into $page[„current‟]
     2.    Invokes <module>_page_build ($page)
               each modules adds its data
     3.       Invokes drupal_alter( $page)
               Your custom module can alter the contents of $page
     4.Invokes drupal_render($page)
   ================================================
block_page_build(„html page‟) (defined in block.module) does the following
   1.  $all_regions = system_region_list($theme);
   2.  for each ($region in $all_regions) {
           if ($blocks = block_get_block_by_regions($region)) {
                  $page[$region] = $blocks;
           endif
       endfor

drupal_alter (module.inc) does the following:
   1.  Invokes each module that has defined <module>_page_alter.
1.     Drupal_render($page) (common.inc) hands over to the presentation
       layer (ie. Theming)
     1.   Recursively invokes „theme()‟ to generate HTML code
          First it calls page.tpl.php for Bartik
          Next it calls html.tpl.php from system module
   Searchable & editable array with key-     $page = array(
    value pairs. Keys are searchable                '#show_messages' => TRUE,
                                                   „#theme_wrappers‟=> „html‟

   the data used to build a page is kept         '#theme' => 'page',
    as render_array until they are ready to       '#type' => 'page',
    be displayed using user selected
                                                  'content' => array(
    theme                                                'system_main' => array(...),
                                                         'another_block' => array(...),
   Allows flexibility in changing the                   '#sorted' => TRUE,
    layout or content of a page                       ),
                                                  'sidebar_first' => array(
                                                         ...
   Alter and preprocess functions work                ),
    with Render Array                             'sidebar_second' => array(
                                                         ...
Rendering = transforming render array                  ),
    into HTML                                      'footer' => array(
                                                         ...
render([page[„content‟]) =                             )
    drupal_render(page[„content‟]);
   _http://chicago2011.drupal.org/sessions/render-api-drupal-7
    (franz heinzmann)

   _http://www.archive.org/details/PageRenderDrillDownInDrupal7
    (moshe wiseman)

   _http://pingv.com/blog/a-peek-at-drupal-7-theme-system-changes
    _http://pingv.com/blog/grok-drupal-7-theming-update
    (Laura Scott)

   _http://drupal.org/node/930760 (render arrays in Drupal 7)
Questions?

Contenu connexe

Tendances

Drupal 8 Sample Module
Drupal 8 Sample ModuleDrupal 8 Sample Module
Drupal 8 Sample Moduledrubb
 
Drupal 8: Forms
Drupal 8: FormsDrupal 8: Forms
Drupal 8: Formsdrubb
 
Drupal Camp Porto - Developing with Drupal: First Steps
Drupal Camp Porto - Developing with Drupal: First StepsDrupal Camp Porto - Developing with Drupal: First Steps
Drupal Camp Porto - Developing with Drupal: First StepsLuís Carneiro
 
Config management
Config managementConfig management
Config managementAlexei Goja
 
JavaScript in Drupal 7: What developers need to know
JavaScript in Drupal 7: What developers need to knowJavaScript in Drupal 7: What developers need to know
JavaScript in Drupal 7: What developers need to knowkatbailey
 
Changes to Drupal Themes in version 7 (part 1)
Changes to Drupal Themes in version 7 (part 1)Changes to Drupal Themes in version 7 (part 1)
Changes to Drupal Themes in version 7 (part 1)Chris Charlton
 
Staying Sane with Drupal NEPHP
Staying Sane with Drupal NEPHPStaying Sane with Drupal NEPHP
Staying Sane with Drupal NEPHPOscar Merida
 
jQuery and_drupal
jQuery and_drupaljQuery and_drupal
jQuery and_drupalBlackCatWeb
 
Phase2 OpenPublish Presentation SF SemWeb Meetup, April 28, 2009
Phase2 OpenPublish Presentation SF SemWeb Meetup, April 28, 2009Phase2 OpenPublish Presentation SF SemWeb Meetup, April 28, 2009
Phase2 OpenPublish Presentation SF SemWeb Meetup, April 28, 2009Krista Thomas
 
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
 
No Coding Necessary: Building User Macros and Dynamic Reports Inside Confluen...
No Coding Necessary: Building User Macros and Dynamic Reports Inside Confluen...No Coding Necessary: Building User Macros and Dynamic Reports Inside Confluen...
No Coding Necessary: Building User Macros and Dynamic Reports Inside Confluen...Atlassian
 
No Coding Necessary: Building Confluence User Macros Cheat Sheet - Atlassian ...
No Coding Necessary: Building Confluence User Macros Cheat Sheet - Atlassian ...No Coding Necessary: Building Confluence User Macros Cheat Sheet - Atlassian ...
No Coding Necessary: Building Confluence User Macros Cheat Sheet - Atlassian ...Atlassian
 
Magento 2 | Declarative schema
Magento 2 | Declarative schemaMagento 2 | Declarative schema
Magento 2 | Declarative schemaKiel Pykett
 
Drupal Step-by-Step: How We Built Our Training Site, Part 1
Drupal Step-by-Step: How We Built Our Training Site, Part 1Drupal Step-by-Step: How We Built Our Training Site, Part 1
Drupal Step-by-Step: How We Built Our Training Site, Part 1Acquia
 
Анатолий Поляков - Drupal.ajax framework from a to z
Анатолий Поляков - Drupal.ajax framework from a to zАнатолий Поляков - Drupal.ajax framework from a to z
Анатолий Поляков - Drupal.ajax framework from a to zLEDC 2016
 

Tendances (20)

Drupal 8 Sample Module
Drupal 8 Sample ModuleDrupal 8 Sample Module
Drupal 8 Sample Module
 
Drupal 8: Forms
Drupal 8: FormsDrupal 8: Forms
Drupal 8: Forms
 
Drupal Camp Porto - Developing with Drupal: First Steps
Drupal Camp Porto - Developing with Drupal: First StepsDrupal Camp Porto - Developing with Drupal: First Steps
Drupal Camp Porto - Developing with Drupal: First Steps
 
Drupal 8 Services
Drupal 8 ServicesDrupal 8 Services
Drupal 8 Services
 
Config management
Config managementConfig management
Config management
 
JavaScript in Drupal 7: What developers need to know
JavaScript in Drupal 7: What developers need to knowJavaScript in Drupal 7: What developers need to know
JavaScript in Drupal 7: What developers need to know
 
Changes to Drupal Themes in version 7 (part 1)
Changes to Drupal Themes in version 7 (part 1)Changes to Drupal Themes in version 7 (part 1)
Changes to Drupal Themes in version 7 (part 1)
 
An Introduction to Drupal
An Introduction to DrupalAn Introduction to Drupal
An Introduction to Drupal
 
Staying Sane with Drupal NEPHP
Staying Sane with Drupal NEPHPStaying Sane with Drupal NEPHP
Staying Sane with Drupal NEPHP
 
jQuery and_drupal
jQuery and_drupaljQuery and_drupal
jQuery and_drupal
 
Drupal 8 Hooks
Drupal 8 HooksDrupal 8 Hooks
Drupal 8 Hooks
 
Phase2 OpenPublish Presentation SF SemWeb Meetup, April 28, 2009
Phase2 OpenPublish Presentation SF SemWeb Meetup, April 28, 2009Phase2 OpenPublish Presentation SF SemWeb Meetup, April 28, 2009
Phase2 OpenPublish Presentation SF SemWeb Meetup, April 28, 2009
 
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
 
No Coding Necessary: Building User Macros and Dynamic Reports Inside Confluen...
No Coding Necessary: Building User Macros and Dynamic Reports Inside Confluen...No Coding Necessary: Building User Macros and Dynamic Reports Inside Confluen...
No Coding Necessary: Building User Macros and Dynamic Reports Inside Confluen...
 
No Coding Necessary: Building Confluence User Macros Cheat Sheet - Atlassian ...
No Coding Necessary: Building Confluence User Macros Cheat Sheet - Atlassian ...No Coding Necessary: Building Confluence User Macros Cheat Sheet - Atlassian ...
No Coding Necessary: Building Confluence User Macros Cheat Sheet - Atlassian ...
 
Magento 2 | Declarative schema
Magento 2 | Declarative schemaMagento 2 | Declarative schema
Magento 2 | Declarative schema
 
Drupal Step-by-Step: How We Built Our Training Site, Part 1
Drupal Step-by-Step: How We Built Our Training Site, Part 1Drupal Step-by-Step: How We Built Our Training Site, Part 1
Drupal Step-by-Step: How We Built Our Training Site, Part 1
 
Alfredo-PUMEX
Alfredo-PUMEXAlfredo-PUMEX
Alfredo-PUMEX
 
Анатолий Поляков - Drupal.ajax framework from a to z
Анатолий Поляков - Drupal.ajax framework from a to zАнатолий Поляков - Drupal.ajax framework from a to z
Анатолий Поляков - Drupal.ajax framework from a to z
 
RicoLiveGrid
RicoLiveGridRicoLiveGrid
RicoLiveGrid
 

Similaire à Drupal 7 Theming - Behind the scenes

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 Theme Development - DrupalCon Chicago 2011
Drupal Theme Development - DrupalCon Chicago 2011Drupal Theme Development - DrupalCon Chicago 2011
Drupal Theme Development - DrupalCon Chicago 2011Ryan Price
 
The Render API in Drupal 7
The Render API in Drupal 7The Render API in Drupal 7
The Render API in Drupal 7frandoh
 
Intro To jQuery In Drupal
Intro To jQuery In DrupalIntro To jQuery In Drupal
Intro To jQuery In DrupalMatthew Farina
 
Theming Drupal: Beyond the Look and Feel
Theming Drupal: Beyond the Look and FeelTheming Drupal: Beyond the Look and Feel
Theming Drupal: Beyond the Look and FeelChris Albrecht
 
Web applications with Catalyst
Web applications with CatalystWeb applications with Catalyst
Web applications with Catalystsvilen.ivanov
 
What's new in the Drupal 7 API?
What's new in the Drupal 7 API?What's new in the Drupal 7 API?
What's new in the Drupal 7 API?Alexandru Badiu
 
Building Potent WordPress Websites
Building Potent WordPress WebsitesBuilding Potent WordPress Websites
Building Potent WordPress WebsitesKyle Cearley
 
Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011
Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011
Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011camp_drupal_ua
 
Drupal Themes
Drupal ThemesDrupal Themes
Drupal Themesakosh
 
WordPress Structure and Best Practices
WordPress Structure and Best PracticesWordPress Structure and Best Practices
WordPress Structure and Best Practicesmarkparolisi
 
Nickolay Shmalenuk.Render api eng.DrupalCamp Kyiv 2011
Nickolay Shmalenuk.Render api eng.DrupalCamp Kyiv 2011Nickolay Shmalenuk.Render api eng.DrupalCamp Kyiv 2011
Nickolay Shmalenuk.Render api eng.DrupalCamp Kyiv 2011camp_drupal_ua
 
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
 
Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...
Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...
Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...LEDC 2016
 
Migrate yourself. code -> module -> mind
Migrate yourself. code -> module -> mindMigrate yourself. code -> module -> mind
Migrate yourself. code -> module -> mindValentine Matsveiko
 
Ruby on Rails - Introduction
Ruby on Rails - IntroductionRuby on Rails - Introduction
Ruby on Rails - IntroductionVagmi Mudumbai
 
13th Sep, Drupal 7 advanced training by TCS
13th Sep, Drupal 7 advanced training by TCS 13th Sep, Drupal 7 advanced training by TCS
13th Sep, Drupal 7 advanced training by TCS DrupalMumbai
 

Similaire à Drupal 7 Theming - Behind the scenes (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 Theme Development - DrupalCon Chicago 2011
Drupal Theme Development - DrupalCon Chicago 2011Drupal Theme Development - DrupalCon Chicago 2011
Drupal Theme Development - DrupalCon Chicago 2011
 
The Render API in Drupal 7
The Render API in Drupal 7The Render API in Drupal 7
The Render API in Drupal 7
 
Intro To jQuery In Drupal
Intro To jQuery In DrupalIntro To jQuery In Drupal
Intro To jQuery In Drupal
 
Drupal theming
Drupal themingDrupal theming
Drupal theming
 
Drupal 7 database api
Drupal 7 database api Drupal 7 database api
Drupal 7 database api
 
Theming Drupal: Beyond the Look and Feel
Theming Drupal: Beyond the Look and FeelTheming Drupal: Beyond the Look and Feel
Theming Drupal: Beyond the Look and Feel
 
Web applications with Catalyst
Web applications with CatalystWeb applications with Catalyst
Web applications with Catalyst
 
What's new in the Drupal 7 API?
What's new in the Drupal 7 API?What's new in the Drupal 7 API?
What's new in the Drupal 7 API?
 
Building Potent WordPress Websites
Building Potent WordPress WebsitesBuilding Potent WordPress Websites
Building Potent WordPress Websites
 
Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011
Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011
Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011
 
Drupal Themes
Drupal ThemesDrupal Themes
Drupal Themes
 
WordPress Structure and Best Practices
WordPress Structure and Best PracticesWordPress Structure and Best Practices
WordPress Structure and Best Practices
 
Nickolay Shmalenuk.Render api eng.DrupalCamp Kyiv 2011
Nickolay Shmalenuk.Render api eng.DrupalCamp Kyiv 2011Nickolay Shmalenuk.Render api eng.DrupalCamp Kyiv 2011
Nickolay Shmalenuk.Render api eng.DrupalCamp Kyiv 2011
 
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
 
Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...
Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...
Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...
 
Migrate yourself. code -> module -> mind
Migrate yourself. code -> module -> mindMigrate yourself. code -> module -> mind
Migrate yourself. code -> module -> mind
 
Ruby on Rails - Introduction
Ruby on Rails - IntroductionRuby on Rails - Introduction
Ruby on Rails - Introduction
 
13th Sep, Drupal 7 advanced training by TCS
13th Sep, Drupal 7 advanced training by TCS 13th Sep, Drupal 7 advanced training by TCS
13th Sep, Drupal 7 advanced training by TCS
 

Dernier

Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 

Dernier (20)

Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 

Drupal 7 Theming - Behind the scenes

  • 1. hook HOOK Ramu Ramakesavan Phoenix Drupal User Group January 2012
  • 2. Client Side Server Side HTML Apache Webserver CSS Style Sheets PHP, Perl JavaScripts MySQL Drupal Framework AJAX Themes, Regions, Blocks Forms, Views, Panels Drupal Administration Installation Module, Hooks Updates/ Upgrades Caching Crawlers Debug
  • 3.
  • 4. Display of data on the webpage • Structured presentation • Site specific modifications to presentation • Creation of data for the webpage • Drupal7 mechanism for data creation • flow of control during data creation (PHP code) • Site specific modifications to data creation • Searchable and editable data format
  • 5. themes/bartik/bartik.info Option „Demo block regions‟ under structure/block in adminstration
  • 7. template_preprocess; template_preprocess_<theme_element> • (web/includes/theme.inc) • default variables for all theme element/ specific theme elements • theme_element: page, html, block, region, maintenance_page • <mymod>_preprocess; <mymod>_preprocess_<theme_element> • (web/sites/all/modules/<mymod>) • modules that didn't define the theme hook can alter the variables. • <ENGINE>_engine_preprocess;<ENGINE>_engine_preprocess_<them e_element> • (web/themes/engines/phptemplate/phptemple.engine) • Drupal uses PHPTemplate as default engine • <THEME>_preprocess; <THEME>_preprocess_ <theme_element> • (web/sites/all/theme/template.php) • Theme Bartik can set variables
  • 8. template_process; template_process_<theme_element> • (web/includes/theme.inc) • default variables for all theme element/ specific theme elements • theme_element: page, html, block, region, maintenance_page • <mymod>_process; <mymod>_process_<theme_element> • (web/sites/all/modules/<mymod>) • modules that didn't define the theme hook can alter the variables. • <ENGINE>_engine_process;<ENGINE>_engine_process_<theme_ele ment> • (web/themes/engines/phptemplate/phptemple.engine) • Drupal uses PHPTemplate as default engine • <THEME>_process; <THEME>_process_ <theme_element> • (web/sites/all/theme/template.php) • Theme Bartik can set variables
  • 9. If implemented using a real function instead of page.tpl.php then only XXXX_preprocess_<theme_element> XXXX_process_<theme_element> routines are executed  Pre_process/process functions can define theme_hook_suggestion and s theme_hook_suggestion that can override current theme implementation  links_contextual_node defines fallback implementations for named objects / contexts  Function a_b_c  Function a_b  Function a Question: When should these capabilities be used?
  • 10. Display of data on the webpage • Structured presentation • Site specific modifications to presentation • Creation of data for the webpage • Drupal7 mechanism for data creation • flow of control during data creation (PHP code) • Site specific modifications to data creation • Searchable and editable data format
  • 11. A web-page is created when a http://www.ramustores.com/?q=examples/theming_example is entered at the URL box in a browser  A web-page is updated when a Menu item that is assigned http://www.ramustores.com/?q=examples/theming_example is selected  Modules register path-CBfunction mapping that are stored in menu_router table Simplified URL works on top of this?
  • 12. function <mymodule>_menu() { $items['examples/theming_example'] = array( 'title' => 'Theming Example', 'description' => 'Some theming examples.', 'page callback' => 'theming_example_page', 'access callback' => TRUE, 'access arguments' => array('access content'), ); $items['examples/theming_example/theming_example_list_page'] = array( 'title' => 'Theming a list', 'page callback' => 'theming_example_list_page', 'access arguments' => array('access content'), 'weight' => 1, ); return $items; }
  • 13. function theming_example_page() { $content[0] = t('Some examples of pages and forms that are run through theme functions.'); $content[1] = l(t('Simple page with a list'), 'examples/theming_example/theming_example_list_page'); $content[2] = l(t('Simple form 1'), 'examples/theming_example/theming_example_order_form'); $content[3] = l(t('Simple form 2'), 'examples/theming_example/theming_example_text_form'); $content['#theme_wrappers'] = array('theming_example_content_array'); return $content; }
  • 14. 1, User enters URL _http://localhost/web/?q=examples/theming_example 2. Drupal executes code in web/index.php  invokes function menu_execute_active_handler 3. menu_execute_active_handler (menu.inc) does the following  searches menu_router for (examples/theming_example) and gets corresponding CallBackFunction.  MainContent=CBfunction(“examples/theming_example”)  drupal_deliver_page(MainContent, HTML (not AJAX or XML)) defined in menu.inc 4. Drupal_deliver_page (common.inc) does the following:  drupal_deliver_html_page (MainContent) 5. Drupal_deliver_html_page (common.inc) does the following:  drupal_render_page(MainContent)
  • 15. 1. drupal_render_page($MainContent) (common.inc) does the following: 1. Copies the $MainContent into $page[„current‟] 2. Invokes <module>_page_build ($page)  each modules adds its data 3. Invokes drupal_alter( $page)  Your custom module can alter the contents of $page 4.Invokes drupal_render($page) ================================================ block_page_build(„html page‟) (defined in block.module) does the following 1. $all_regions = system_region_list($theme); 2. for each ($region in $all_regions) { if ($blocks = block_get_block_by_regions($region)) { $page[$region] = $blocks; endif endfor drupal_alter (module.inc) does the following: 1. Invokes each module that has defined <module>_page_alter.
  • 16. 1. Drupal_render($page) (common.inc) hands over to the presentation layer (ie. Theming) 1. Recursively invokes „theme()‟ to generate HTML code  First it calls page.tpl.php for Bartik  Next it calls html.tpl.php from system module
  • 17. Searchable & editable array with key- $page = array( value pairs. Keys are searchable '#show_messages' => TRUE, „#theme_wrappers‟=> „html‟  the data used to build a page is kept '#theme' => 'page', as render_array until they are ready to '#type' => 'page', be displayed using user selected 'content' => array( theme 'system_main' => array(...), 'another_block' => array(...),  Allows flexibility in changing the '#sorted' => TRUE, layout or content of a page ), 'sidebar_first' => array( ...  Alter and preprocess functions work ), with Render Array 'sidebar_second' => array( ... Rendering = transforming render array ), into HTML 'footer' => array( ... render([page[„content‟]) = ) drupal_render(page[„content‟]);
  • 18. _http://chicago2011.drupal.org/sessions/render-api-drupal-7 (franz heinzmann)  _http://www.archive.org/details/PageRenderDrillDownInDrupal7 (moshe wiseman)  _http://pingv.com/blog/a-peek-at-drupal-7-theme-system-changes _http://pingv.com/blog/grok-drupal-7-theming-update (Laura Scott)  _http://drupal.org/node/930760 (render arrays in Drupal 7)