Think Like a Drupal Developer


Published on

Drupal is hard. It's not just a CMS, it's not just a framework, it has the power of both and the simplicity of neither. So where do you get started?

This session will bring developers new to Drupal up-to-speed on exactly what they need to know to tackle that next big Drupal project. You will learn not about the newest and greatest modules and performance tricks, but instead about how a Drupal developers thinks and solve problems. Once you understand what Drupal wants from you, it's much easier to conquer any crazy requirement a client may give.

The best Drupal developers are lazy developers. Meaning that they only develop what's necessary to solve the problem and use the wealth of contributed modules to help them get there. Many new developers coming from handmade web sites tend to over-develop and waste time solving problems others have already solved or problems Drupal can already solve for you. This session will make you more efficient, saving you time and helping you get your projects out the door faster!

Published in: Technology
1 Comment
  • Looks like a great preso, but much of the text is unreadable :(
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Think Like a Drupal Developer

  1. 1. Think  Like  a  Drupal  DeveloperErik WebbTechnical Consultant, Acquia Drupalcamp Atlanta 2011
  2. 2. Who  am  I?• Joined Acquia in April 2010• 30+ clients in almost 2 dozen states• Systems administrator background (RHCE)• LAMP development (10+ years PHP)• Go Jackets! Drupalcamp Atlanta 2011
  3. 3. Who  are  you? Drupalcamp Atlanta 2011
  4. 4. Drupal  is  hard.  Its  not  just  a  CMS,  its  not  just  a  framework,  it  has  the  power  of  both  and  the  simplicity  of  neither.  So  where  do  you  get  started? Drupalcamp Atlanta 2011
  5. 5. How  Drupal  works1. Lookup URL in aliases, menu router2. Check for cached page3. Check permissions for page4. Run page callback5. Process render array Drupalcamp Atlanta 2011
  6. 6. What  Drupal  Can  Do• Managing lots of structured data• Strictly manage access to content and functionality• Providing an organized administration section• Allowing themers great flexibility• Using common page layouts Drupalcamp Atlanta 2011
  7. 7. Coders  vs.  Builders• We’re all developers• Good Drupal developers are “lazy” • Efficiency beats all • Enjoy your weekends!• Trust the community• Rethink problems, not solutions Drupalcamp Atlanta 2011
  8. 8. Building  vs.  Coding• Building • Coding • Flatter learning curve • Steep learning curve • Easier transition for “web • Easier transition for developers” programmers • More maintainable* • Less maintainable* • Dependent on community • Customized to client • Book learnin’ • Blood, sweat, & tears • Faster development • Faster performance* • Reusable solutions • One-off advantages Drupalcamp Atlanta 2011
  9. 9. What  to  code Drupalcamp Atlanta 2011
  10. 10. Modifying  Forms• hook_form_alter(), hook_form_FORM_ID_alter()• Administrative and user-facing forms• Examples • Making individual fields required • Changing order of fields • Adding help text • Additional validation or submission handlers Drupalcamp Atlanta 2011
  11. 11. Changing  Nodes• Structure • Presentation • hook_node_view() • template_preprocess_nod • Add new data e() • Modify existing data • Reformat data • Change data in all places • Combine into pseudo- fields • NEVER alter data, treat as read-only Drupalcamp Atlanta 2011
  12. 12. Menu  Manipulation• hook_menu_alter()• Change menu properties • Hide links globally • Change title • Change permissions • Override callbacks• Efficient, runs only on cache clear Drupalcamp Atlanta 2011
  13. 13. When  to  code  or  build Drupalcamp Atlanta 2011
  14. 14. Content  Aggregation• Views • EntityFieldQuery • Graphical setup • Full control* • Community-driven • Low overhead • Built-in caching • Extremely Drupal-specific • Many display options • No SQL! • Efficient prototyping • Combine with Entity Load Cache* Drupalcamp Atlanta 2011
  15. 15. Contextual  Changes• Context module • hook_boot(), • Flexible API hook_init() • Easily exportable to code • Completely custom • Extendable by non-coders • Performance-focused • Handling condition and reactions Drupalcamp Atlanta 2011
  16. 16. ExamplesDrupalcamp Atlanta 2011
  17. 17. Client:  Anytime  an  anonymous  user  visits  a  news  article,  I  want  to  show  them  a  modal  with  a  subscription  link. Drupalcamp Atlanta 2011
  18. 18. Use  Context• Wrong way • template_preprocess_node() to add JS in a theme• Right way • Create a modal reaction for Context • Why not use hook_boot()?• Right way • Use pure JavaScript to check for body.logged-in CSS class Drupalcamp Atlanta 2011
  19. 19. Client:  I  don’t  want  anonymous  users  seeing  any  content  tagged  with  the  “Internal”  keyword. Drupalcamp Atlanta 2011
  20. 20. Nodes  are  everywhere!• Wrong way • hook_node_access() doesn’t affect the menu• Wrong way • Override ‘access callback’ for URL ‘node/%’• Wrong way • hook_node_view() returns drupal_access_denied()• Right way • hook_node_access_records() changes all node accessing Drupalcamp Atlanta 2011
  21. 21. Client:  I  want  all  checkboxes  to  be  those  cool  image  buttons  instead  of  the  normal  checks. Drupalcamp Atlanta 2011
  22. 22. Form  altering  isn’t  always  the  right  way• Wrong way • Use CSS/JS to change input[type=”checkbox”]• Wrong way • Use hook_form_alter() to change the ‘#theme’ property for all checkboxes to your theme function• Right way • Simply create modulename_checkbox() to override all uses of the form element Drupalcamp Atlanta 2011
  23. 23. Client:  I  want  to  incorporate  my  company-­‐wide  header/masthead  into  my  Drupal  site. Drupalcamp Atlanta 2011
  24. 24. iframe?  What  is  this,  1999?• Wrong way • Hard code into an include file in your theme• Wrong way • Recreate the header using Drupal’s menu system and CSS• Right way • Create a JS include somewhere else• Right way • Use a web service to retrieve the HTML (and cache it!) Drupalcamp Atlanta 2011
  25. 25. Questions?Ask me - @erikwebb on Twitter Drupalcamp Atlanta 2011