Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Theme like a monster #ddceu

2,203 views

Published on

Based on the blog posts Drupal theming nightmares at http://sotak.co.uk/blog

  • Be the first to comment

Theme like a monster #ddceu

  1. 1. june 2 0 1 1THEME LIKE A MONSTER MAREK SOTAK | ATOMIC ANT www.atomicant.co.uk
  2. 2. OH HAI!ABOUT ME & ATOMIC ANT ● Web designer, developer ● Over 5 years with Drupal - since v4.6 ● International team ● active in Drupal community - rootcandy, organising events@sotak -- http://sotak.co.uk - http://atomicant.co.uk
  3. 3. DREAM JOB!NOT REALLY ● Theyve called in ● Job I didnt really want to do ● Little tweaks, thats what theyve said
  4. 4. DREAM JOB!NOT REALLY
  5. 5. DREAM JOB!NOT REALLY
  6. 6. DREAM JOB!NOT REALLY
  7. 7. OH WELLOH YEAH ● theme in /themes folder ● multisite approach? no? - http://drupal.org/node/53705
  8. 8. OH WELLOH YEAH ● cloning Garland (any contrib theme - how to) ● you better sub-theme! - http://drupal.org/node/225125
  9. 9. LIKE A SHERLOCKOH YEAH ● Ctrl+U, browsing the themes folder, wait...
  10. 10. LIKE A SHERLOCKOH YEAH ● 109 files? structure? Problem?
  11. 11. LIKE A SHERLOCKOH YEAH
  12. 12. THAT MOMENTNIGHTMARE NO. 1 ● How many libraries you have? Sorry? ● elmstreet.infojsearchbox.js - custom js, copied? a js function getElementsByClassName?
  13. 13. HARDCODEDNIGHTMARE NO. 2 ● hardcoded <link>s and <script>s <head> <?php print $head ?> <title><?php print $head_title ?></title> <link type="text/css" rel="stylesheet" media="all" href="<?php echo base_path() . path_to_theme();?>/common.css?G" /> <link type="text/css" rel="stylesheet" media="all" href="<?php echo base_path() . path_to_theme();?>/style.css?G" /> <link type="text/css" rel="stylesheet" media="all" href="<?php echo base_path() . path_to_theme();?>/pc-menu.css?G" /> <?php print $scripts ?> </head>
  14. 14. HARDCODEDNIGHTMARE NO. 2 ● no $styles variable? ● how about drupal/modules css? ● aggregation? ● exception hardcoded link - conditional stylesheets ● want to remove styles? do it in .info file stylesheets[all][] = system-menus.css hook_css_alter();
  15. 15. $CLOSURENIGHTMARE NO. 3 ● page.tpl.php </div> <?php require_once($_SERVER[DOCUMENT_ROOT] ."/themes/elmstreet/google_analytics.php"); ?> </body> </html> ● oh, you already have google analytics module?
  16. 16. C A M P B L O O D F R I D A Y 1 3 thNIGHTMARE NO. 4 ● template.php ● Copy, paste but THINK!
  17. 17. C A M P B L O O D F R I D A Y 1 3 thNIGHTMARE NO. 4 ● functions like garland_xxx - leftovers ● custom functions get_user(), groupdetails(),... ○ _mytheme_get_user(), mytheme_groupdetails()
  18. 18. SQL QUERIESNIGHTMARE NO. 5 JUST DONT
  19. 19. FORM API MISUSENIGHTMARE NO. 6 ● Oh Hai "elmstreet_mysearchform" in template.php ● FAPI syntax, returns form array - but where is this being called from? ● in page.tpl.php via drupal_get_form?
  20. 20. UNEXPLAINABLENIGHTMARE NO. 7 ● Remember? ● So they probably wanted to have a template suggestions for specific pages incl. headers
  21. 21. UNEXPLAINABLENIGHTMARE NO. 7<?php $nodenid = $node->nid; ?><?php if ($nodenid == 142) { include(page_mpffe.tpl.php); return; } ?><?php if ($nodenid == 131) { include(page_sca.tpl.php); return; } ?><?php if ($override == mpffe) { include(page_mpffe_other.tpl.php);return; } ?><?php if ($override == sca) { include(page_sca_other.tpl.php); return; } ?><?php if ($override == cppce) { include(page_cppce_other.tpl.php); return;} ?><?php if ($override == ankpg) { include(page_ankpg_other.tpl.php);return; } ?>
  22. 22. UNEXPLAINABLENIGHTMARE NO. 7 ● we have custom suggestions ○ D6 - template_files, template_file ○ D7 - $variables[theme_hook_suggestions]
  23. 23. OKAYCONCLUSION
  24. 24. QUESTIONSGOT ANY NIGHTMARES?twitter: @sotakhttp://sotak.co.ukhttp://atomicant.co.uk

×