Hong Kong Drupal User Group
(HKDUG)
Overriding Themable Output in Drupal 7
DrupalCamp Hong Kong
2014 June 14th
Edison Wong
● CEO, PantaRei Design
– hswong3i@pantarei-design.com
● Drupal developer & contributor
– https://drupal.org/us...
PantaRei Design
● Hong Kong based Free and Open Source Software (FOSS) service
provider
– Content Management System (CMS) ...
Outline
● What is Drupal Theme?
● Why Override Themable Output?
● How To Override Themable Output?
What is Drupal Theme?
● Can change the appearance of an entire site
● Change layouts, images or fonts
● Hide or display fi...
Why Override Themable Output?
● Don't hack core!
● Modify HTML markup
– Change HTML the Drupal way
– Using PHP for theming...
How To Override Themable Output?
● Avoiding having to override at all
– Can you just change a setting?
– Can you accomplis...
Overriding theme functions
● Open your theme's template.php file in a plain
text editor
● Copy the theme or template funct...
Overriding theme functions (cont.)
● https://api.drupal.org/api/drupal/includes!theme.inc/
● https://api.drupal.org/api/dr...
Overriding a theme file
● Copy the theme file to your theme directory
● Modify the file so it does what you want it to do
...
Overriding a theme file (cont.)
● https://api.drupal.org/api/drupal/modules!node!node
● https://api.drupal.org/api/drupal/...
Finding where the themable output
is coming from
● Finding the source
● Understand the system of overrides
● “Function” vs...
Q&A
References
● https://drupal.org/node/341628
● https://drupal.org/node/457740
● https://drupal.org/node/173880
I Need More Help!
● Read documents from Drupal Community
– https://drupal.org/documentation
● Join Hong Kong Drupal User G...
Thank You
● Please feel free to contact us:
– Unit 207, 2/F IC Development Centre, No.6 Science
Park West Avenue, Hong Kon...
Hong Kong Drupal User Group - 2014 June 14th
Hong Kong Drupal User Group - 2014 June 14th
Hong Kong Drupal User Group - 2014 June 14th
Hong Kong Drupal User Group - 2014 June 14th
Hong Kong Drupal User Group - 2014 June 14th
Hong Kong Drupal User Group - 2014 June 14th
Hong Kong Drupal User Group - 2014 June 14th
Hong Kong Drupal User Group - 2014 June 14th
Hong Kong Drupal User Group - 2014 June 14th
Hong Kong Drupal User Group - 2014 June 14th
Hong Kong Drupal User Group - 2014 June 14th
Hong Kong Drupal User Group - 2014 June 14th
Hong Kong Drupal User Group - 2014 June 14th
Upcoming SlideShare
Loading in …5
×

Hong Kong Drupal User Group - 2014 June 14th

324 views
275 views

Published on

Overriding Themable Output in Drupal 7

Published in: Technology, Health & Medicine
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
324
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Hong Kong Drupal User Group - 2014 June 14th

  1. 1. Hong Kong Drupal User Group (HKDUG) Overriding Themable Output in Drupal 7 DrupalCamp Hong Kong 2014 June 14th
  2. 2. Edison Wong ● CEO, PantaRei Design – hswong3i@pantarei-design.com ● Drupal developer & contributor – https://drupal.org/user/33940 ● HKDUG Co-founder – https://groups.drupal.org/drupalhk ● Startup founder – 2009 - PantaRei Design founded – 2010 - YBHK applicant – 2011 - ITF SERAP applicant – 2011 - HKSTP Incu-Tech applicant
  3. 3. PantaRei Design ● Hong Kong based Free and Open Source Software (FOSS) service provider – Content Management System (CMS) with Drupal – Cloud hosting with Amazon Web Services (AWS) ● Business Partnership – 2012 - AWS Consulting Partner – 2013 - Acquia Partner – 2013 - Atlassian Experts – 2014 - Rackspace Hosting Partner ● FOSS Contributor – 2008 - Hong Kong Drupal User Group Co-founder – 2012 - Drupal Services Provider
  4. 4. Outline ● What is Drupal Theme? ● Why Override Themable Output? ● How To Override Themable Output?
  5. 5. What is Drupal Theme? ● Can change the appearance of an entire site ● Change layouts, images or fonts ● Hide or display fields dependent on user role ● Dynamically respond to changes in the content or to user input
  6. 6. Why Override Themable Output? ● Don't hack core! ● Modify HTML markup – Change HTML the Drupal way – Using PHP for theming ● Overriding CSS
  7. 7. How To Override Themable Output? ● Avoiding having to override at all – Can you just change a setting? – Can you accomplish your goal through CSS? ● Overriding theme functions ● Overriding a theme file ● Finding where the themable output is coming from
  8. 8. Overriding theme functions ● Open your theme's template.php file in a plain text editor ● Copy the theme or template function you found into your template.php file ● Rename the function you copied in, e.g. – From “function theme_xyz($a, $b, $c) {“ – To “function wonderful_xyz($a, $b, $c) {“
  9. 9. Overriding theme functions (cont.) ● https://api.drupal.org/api/drupal/includes!theme.inc/ ● https://api.drupal.org/api/drupal/themes!garland!tem
  10. 10. Overriding a theme file ● Copy the theme file to your theme directory ● Modify the file so it does what you want it to do ● Upload the file to your web site, including the new base theme file if necessary, into your theme's directory ● Refresh the theme cache
  11. 11. Overriding a theme file (cont.) ● https://api.drupal.org/api/drupal/modules!node!node ● https://api.drupal.org/api/drupal/themes!garland!nod
  12. 12. Finding where the themable output is coming from ● Finding the source ● Understand the system of overrides ● “Function” vs “Template” ● Using the “Theme developer” module
  13. 13. Q&A
  14. 14. References ● https://drupal.org/node/341628 ● https://drupal.org/node/457740 ● https://drupal.org/node/173880
  15. 15. I Need More Help! ● Read documents from Drupal Community – https://drupal.org/documentation ● Join Hong Kong Drupal User Group – Event organizing: http://www.meetup.com/drupalhk – Technological discussion: https://groups.drupal.org/drupalhk – Business connection: http://www.linkedin.com/groups/?gid=6644792 – General sharing: https://www.facebook.com/groups/drupalhk ● Contact us for one (1) month free-trial support service – http://pantarei-design.com/services/support/#support-service-plans
  16. 16. Thank You ● Please feel free to contact us: – Unit 207, 2/F IC Development Centre, No.6 Science Park West Avenue, Hong Kong Science Park, Shatin, N.T. – +852 3576 3812 – http://pantarei-design.com/ – sales@pantarei-design.com

×