SlideShare ist ein Scribd-Unternehmen logo
1 von 22
 
Overview  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Structure of Theme Files
Each Template Handles A Region of Your Site ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Template Hierarchy Home Page page-front.tpl.php page.tpl.php Nodes node-type.tpl.php node.tpl.php Pages page-node-edit.tpl.php page-node-1.tpl.php page-node.tpl.php page.tpl.php Blocks block-module-delta.tpl.php block-module.tpl.php block-region.tpl.php block.tpl.php Boxes box.tpl.php Comments comment.tpl.php
Theme() execution hierarchy ,[object Object],[object Object],[object Object],[object Object]
Available templates for module ,[object Object],[object Object],[object Object],[object Object]
Tool helps in theming ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Devel: dpm() Firebug:  To  inspect HTML and CSS, and prototype styles( http://getfirebug.com ) Web Developer Toolbar:  Adds a menu and a toolbar to Firefox with various helpful web developer tools.  https://addons.mozilla.org/en-US/firefox/addon/60 XDebug & NetBeans
Drupal for Firebug:  Install the  Drupal for Firebug module
Exploring for theme ,[object Object],[object Object],[object Object],[object Object]
Ex 1: How to Call theme() ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Step1) hook_menu() implementation function drupalcamp_menu(){ $items['my-themeing-page'] = array( 'title' => 'General page callback', 'page callback' => 'drupalcamp_page_theming', 'access arguments' => array('access content'), 'type' => MENU_NORMAL_ITEM ); return $items;  } Step2) hook_preprocess function drupalcamp_preprocess_ drupalcamp_page_theming (&$vars){ $vars['new_variable1'] = 'this is my first variable‘;  }
Step3) hook_theme implementation function drupalcamp_theme(){ $items[' drupalcamp_page_theming '] = array( 'template' => 'drupalcamp-page-theming', 'arguments' => array(), 'access agruments' => TRUE );  return $items;  }  Note the underscores in the theme function name are replaced with hyphens when we create our template reference. Note also that, in theory, the template name does not have to match the theme function name, however, we have discovered through testing that if the template name is different from the theme function name then the theme may not recognise the template file when it is coped to the theme's template directory. I'm not sure if this is by design, but for safety's sake make sure the template file and the theme registration are the same in name.
Step 4) call theme() function function  drupalcamp_page_theming (){ return theme('drupalcamp_page_theming'); } Step 5) Next job is to create our template file  drupalcamp-page-theming.tpl.php <div class=&quot;my-theme&quot;> This is my template. <?php print $new_variable1; ?> </div> Now if you clear the Drupal cache (see below) and we visit the page http://yoursite.com/my-themeing-page then we will see the output of our theme function
Ex 2: Page callback & theme This is similar to example 1 only difference is we added page callback => ‘theme’ and deleted step4 Step1) hook_menu() implementation function drupalcamp_menu(){ $items['my-themeing-page'] = array( 'title' => 'General page callback', 'page callback' => ‘theme', ‘ page arguments’ => array(‘drupalcamp_page_theming’), 'access arguments' => array('access content'), 'type' => MENU_NORMAL_ITEM ); return $items;}
Step2) hook_theme implementation function drupalcamp_theme(){ $items['drupalcamp_page_theming'] = array( 'template' => 'drupalcamp-page-theming', 'arguments' => array(), 'access agruments' => TRUE );  return $items; }  Step3) hook_preprocess function drupalcamp_preprocess_drupalcamp_page_theming(&$vars){ $vars['new_variable1'] = 'this is my first variable'; $vars['goto_back'] = l(‘My Link', ‘my url’, array('attributes' => array('class' => 'orangeBtn'))); }
Ex 3: How to theme a form Step1) hook_menu() implementation function drupalcamp_menu(){ $items['form_theme'] = array( 'title' => 'How to implement theme with a form callback‘,  'page callback' => 'drupal_get_form', 'page arguments' => array('drupalcamp_form'), 'access arguments' => array('access content'), 'type' => MENU_NORMAL_ITEM ); }
Step2) hook_theme implementation function drupalcamp_theme(){ $items['drupalcamp_form'] = array( 'template' => 'drupalcamp-form', 'arguments' => array('form' => NULL), 'access arguments' => TRUE, );  }  Step3) hook_preprocess function drupalcamp_preprocess_drupalcamp_page_theming(&$vars){ $vars[‘about_us'] = l(‘About Us', ‘url’, array('attributes' => array('class' => ‘Btn'))); $image_path = drupal_get_path('module', ‘drupalcamp') . '/images/image.png'; $var[‘my_image'] = theme_image($image_path,'',''); $var['setmessages'] = drupal_get_messages(); $vars[' firstname '] = drupal_render($vars['form'][' firstname ']); $var[‘add_temp'] = theme(' drupalcamp-page-theming '); // Called a template }
Step4) hook_form implementation function drupalcamp_form(){ $form['firstname'] = array( '#type' => 'textfield', '#title' => 'First Name', '#default_value' => 'test', ); return $form; } Step5) Create  drupalcamp-form.tpl.php page <div class=&quot;paymentFooterLnks&quot;> <?php print $about_us;?> </div> <div> <?php print $add_temp;?></div> <div class=&quot;verisign&quot;><?php print $my_image;?></div> <div class=&quot;billing&quot;><?php print  $ firstname ;?> </div> <?php print drupal_render($form);?>
Some Useful Links https://ratatosk.backpackit.com/pub/1836982-debugging-drupal http://drupal.org/project/devel_themer http://mogdesign.eu/blog/performance-tips-for-drupal-theming/ http://www.drupaler.co.uk/blog/theming-drupal-6/96#comment-1504 http://design.acquia.com/content/tools-getting-started http://www.appnovation.com/theming-views-drupal-6-simple-way
Catch me at Mandakini125 (skype) [email_address]

Weitere Àhnliche Inhalte

KĂŒrzlich hochgeladen

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
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
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
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
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
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Mcleodganj Call Girls đŸ„° 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls đŸ„° 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls đŸ„° 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls đŸ„° 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
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
 
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
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 

KĂŒrzlich hochgeladen (20)

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
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
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...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
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
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Mcleodganj Call Girls đŸ„° 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls đŸ„° 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls đŸ„° 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls đŸ„° 8617370543 Service Offer VIP Hot Model
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
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
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 

Empfohlen

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data ScienceChristy Abraham Joy
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Empfohlen (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Theming best practices and preprocess by ayushi infotech

  • 2.
  • 4.
  • 5. Template Hierarchy Home Page page-front.tpl.php page.tpl.php Nodes node-type.tpl.php node.tpl.php Pages page-node-edit.tpl.php page-node-1.tpl.php page-node.tpl.php page.tpl.php Blocks block-module-delta.tpl.php block-module.tpl.php block-region.tpl.php block.tpl.php Boxes box.tpl.php Comments comment.tpl.php
  • 6.
  • 7.
  • 8.
  • 9. Devel: dpm() Firebug: To inspect HTML and CSS, and prototype styles( http://getfirebug.com ) Web Developer Toolbar: Adds a menu and a toolbar to Firefox with various helpful web developer tools. https://addons.mozilla.org/en-US/firefox/addon/60 XDebug & NetBeans
  • 10. Drupal for Firebug: Install the  Drupal for Firebug module
  • 11.
  • 12.
  • 13. Step1) hook_menu() implementation function drupalcamp_menu(){ $items['my-themeing-page'] = array( 'title' => 'General page callback', 'page callback' => 'drupalcamp_page_theming', 'access arguments' => array('access content'), 'type' => MENU_NORMAL_ITEM ); return $items; } Step2) hook_preprocess function drupalcamp_preprocess_ drupalcamp_page_theming (&$vars){ $vars['new_variable1'] = 'this is my first variable‘; }
  • 14. Step3) hook_theme implementation function drupalcamp_theme(){ $items[' drupalcamp_page_theming '] = array( 'template' => 'drupalcamp-page-theming', 'arguments' => array(), 'access agruments' => TRUE ); return $items; } Note the underscores in the theme function name are replaced with hyphens when we create our template reference. Note also that, in theory, the template name does not have to match the theme function name, however, we have discovered through testing that if the template name is different from the theme function name then the theme may not recognise the template file when it is coped to the theme's template directory. I'm not sure if this is by design, but for safety's sake make sure the template file and the theme registration are the same in name.
  • 15. Step 4) call theme() function function drupalcamp_page_theming (){ return theme('drupalcamp_page_theming'); } Step 5) Next job is to create our template file drupalcamp-page-theming.tpl.php <div class=&quot;my-theme&quot;> This is my template. <?php print $new_variable1; ?> </div> Now if you clear the Drupal cache (see below) and we visit the page http://yoursite.com/my-themeing-page then we will see the output of our theme function
  • 16. Ex 2: Page callback & theme This is similar to example 1 only difference is we added page callback => ‘theme’ and deleted step4 Step1) hook_menu() implementation function drupalcamp_menu(){ $items['my-themeing-page'] = array( 'title' => 'General page callback', 'page callback' => ‘theme', ‘ page arguments’ => array(‘drupalcamp_page_theming’), 'access arguments' => array('access content'), 'type' => MENU_NORMAL_ITEM ); return $items;}
  • 17. Step2) hook_theme implementation function drupalcamp_theme(){ $items['drupalcamp_page_theming'] = array( 'template' => 'drupalcamp-page-theming', 'arguments' => array(), 'access agruments' => TRUE ); return $items; } Step3) hook_preprocess function drupalcamp_preprocess_drupalcamp_page_theming(&$vars){ $vars['new_variable1'] = 'this is my first variable'; $vars['goto_back'] = l(‘My Link', ‘my url’, array('attributes' => array('class' => 'orangeBtn'))); }
  • 18. Ex 3: How to theme a form Step1) hook_menu() implementation function drupalcamp_menu(){ $items['form_theme'] = array( 'title' => 'How to implement theme with a form callback‘, 'page callback' => 'drupal_get_form', 'page arguments' => array('drupalcamp_form'), 'access arguments' => array('access content'), 'type' => MENU_NORMAL_ITEM ); }
  • 19. Step2) hook_theme implementation function drupalcamp_theme(){ $items['drupalcamp_form'] = array( 'template' => 'drupalcamp-form', 'arguments' => array('form' => NULL), 'access arguments' => TRUE, ); } Step3) hook_preprocess function drupalcamp_preprocess_drupalcamp_page_theming(&$vars){ $vars[‘about_us'] = l(‘About Us', ‘url’, array('attributes' => array('class' => ‘Btn'))); $image_path = drupal_get_path('module', ‘drupalcamp') . '/images/image.png'; $var[‘my_image'] = theme_image($image_path,'',''); $var['setmessages'] = drupal_get_messages(); $vars[' firstname '] = drupal_render($vars['form'][' firstname ']); $var[‘add_temp'] = theme(' drupalcamp-page-theming '); // Called a template }
  • 20. Step4) hook_form implementation function drupalcamp_form(){ $form['firstname'] = array( '#type' => 'textfield', '#title' => 'First Name', '#default_value' => 'test', ); return $form; } Step5) Create drupalcamp-form.tpl.php page <div class=&quot;paymentFooterLnks&quot;> <?php print $about_us;?> </div> <div> <?php print $add_temp;?></div> <div class=&quot;verisign&quot;><?php print $my_image;?></div> <div class=&quot;billing&quot;><?php print $ firstname ;?> </div> <?php print drupal_render($form);?>
  • 21. Some Useful Links https://ratatosk.backpackit.com/pub/1836982-debugging-drupal http://drupal.org/project/devel_themer http://mogdesign.eu/blog/performance-tips-for-drupal-theming/ http://www.drupaler.co.uk/blog/theming-drupal-6/96#comment-1504 http://design.acquia.com/content/tools-getting-started http://www.appnovation.com/theming-views-drupal-6-simple-way
  • 22. Catch me at Mandakini125 (skype) [email_address]

Hinweis der Redaktion

  1. This is similar to example 1 only difference is we added one extra line page callback =&gt; ‘theme’ and deleted step4