Drupal Best Practices

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

3 comments

Comments 1 - 3 of 3 previous next Post a comment

  • + manugoel2003 manugoel2003 8 months ago
    Hi peremuk, you can definitely embed the presentation using the embed code above... which I guess you already have... I am glad you liked it
  • + OracleLink.com OracleLink.com 2 years ago
    If you want to check out a cool Drupal based site visit OracleLink.com - The Oracle Community Network

    http://www.oraclelink.com
  • + pinolo Marcello Testi 3 years ago
    Very well organized and straight to the point(s). Just a little too much typos.
    Thanks for sharing.
Post a comment
Embed Video
Edit your comment Cancel

32 Favorites & 1 Group

Drupal Best Practices - Presentation Transcript

  1. DRUPAL BEST PRACTICES
  2. We are going to cover...
    • Drupal Best practices for
        • Development Environment
        • Module Development
        • Theme Development
        • Other stuff
  3. Installation
    • Always use the latest CVS code
        • Not necessarily the HEAD version
  4. Geting Drupal from CVS
    • $ cvs -d:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal checkout -r DRUPAL-5 -d mysite drupal
    http://drupal.org/node/93966
  5. Getting contibuted modules
    • $ cd mysite
    • $ cvs checkout -d modules/views -r DRUPAL-5 contributions/modules/views
    • $ cvs checkout -d modules/cck -r DRUPAL-5 contributions/modules/cck
    http://drupal.org/node/93966
  6. Now updates are a snap
    • $ cvs update -dP
    • This gets any updates to the core and the modules for the installed version
  7. Updating to new Drupal version
      • Be sure that contibuted modules have been ported to the new version
      • $ cvs update -r DRUPAL-5-2 -dP
  8. Revision Control you project
    • Subversion users
      • $ cd mysite
      • $ svn import /path/to/svn/repository
    • Bazaar users
      • $ cd mysite
      • $ bzr init
    YOU CANNOT USE CVS HERE
  9. Best Practices so far
    • Get the latest version from CVS
    • Check for updates before going further
    • Get the needed contributed modules from CVS
    • Have your own revision control system in place
      • You do not own Drupal CVS repository
    • Update(CVS) periodically to get latest fixes
    • Don't even try using CVS
  10. Module Development
    • UNDERSTANT
    • ALL
    • PREQUISITES
    • VERY
    • THOUROUGHLY
  11. Make sure you understand
    • Drupal's database schema
    • Just to give you a glimpse
  12.  
  13. Understand hooks
    • Drupal has hooks for every thing
    • CRUD operations
    • Modiying into user data at runtime
    • Modifying almost everything at runtime
    • Path definitions (rails is a bit late here)
    • And much much more
  14. And obiviously
    • You should know
    • PHP
    • SQL
    • Good programming style
  15. Ask questions
        • Is the functionality already available in any contributed module?
      • Is there a contributed module that does something similar that I need?
      • Can I adapt some existing module to do what I need to do?
    `
  16. Code you own modules when needed
    • DO NOT FORCE
    • A DONKEY
    • RUN A DERBY
    • NEITHER FORCE
    • A STALLION
    • TO PULL A CART
  17. If it is a Node Module
    • Try to use
    • Content
    • Construction
    • Kit
    • if possible...
  18. With CCK
    • Use
    • VIEWS
    • Views module provides creating custom views of the node related data and other data as well.
  19. While writing module
    • You will be
    • Creating Forms
    • Recieving input
    • Doing SQL stuff
    • Oupting Stings
      • containing Text, HTML and other content
  20. Use the Form API
    • Form API has benifits
    • Define forms in php syntax
      • Drupal will generate the HTML for you
        • Dupal takes care proper html
        • Makes form alterable at the runtime by other modules
        • Makes programatic submission possible
  21. Convention over Configuration
    • Use Form API conventions
    • <?php
    • function module_form(){
    • //form definitions
    • }
    • ?>
  22. Validate
    • <?php
    • function module_form_validate ($form_id, $form_values) {
      • // do the validation
      • // set the errors
    • }
    • function module_form_submit ($form_id, $form_values) {
      • // perform submit
    • }
    • ?>
  23. Input validation
    • Make sure you check all text only fields with
    • check_plain()
    • It checks for malicious contents in like clever scripts, specially HTML etc.
  24. Othe use full functions
    • filter_xss()
    • check_markup()
    • check_url
    • valid_url()
    • valid_email()
      • Drupal has a very powerfull input filter syetem
    • LEARN IT
    • USE IT
    • No Excuses
  25. SQL
    • CONSTRUCT
    • GOOD
    • QUERIES
  26. BAD SQL...
    • $result = db_query(”SELECT *
    • FROM {node}
    • WHERE
    • uid = $uid”);
  27. Good SQL
    • $result = db_query(”SELECT *
    • FROM {node}
    • WHERE
    • uid = %d”, $uid);
  28. printf style convervsion specs
    • %d = integer
    • $f = float
    • '%s' = sting
    • %b = binary data
    • %% = percent sign
  29. Avoid queries in loop
    • <?php
    • while (some condition) {
    • $res = db_query(”SELECT * FROM
    • {table} WHERE
    • something = something”);
    • }
    • ?>
  30. Bewre of QUERY HELL
    • In some-page.tpl.php
    • $someone = user_load(array('uid' => $uid));
    • call_some_function($uid = $user->uid);
      • function call_some_function($uid){
      • $someone = user_load(array('uid'=>$uid));
      • }
    Reloading user again
  31. Modules and HTML
    • MODULE != HTML
    Never output html directly from module functions BUT DON'T MAKE IT A RELIGION
  32. Example of Module + HTML
    • blog_user_page()
    Generates HTML directly Learn from it
  33. One tip
    • Never
    • Never
    • Never
    use print statement from inside functions
  34. Themes
    • You MUST be strong in
    • HTML
    • CSS
    • JavaScript
    • jQuery
  35. Theme engines
    • Available theme engines
    • PHPTemplate
    • Zengine psedo theme theme engine pased on PHPTemplate
    • Smarty
    • PHPTAL
    • Xtemplate DEPRECATED
    • Pure PHP themes
  36. PHPTemplate
    • The default theme engine since v4.7
    • Simple to learn and use
    • Built for Drupal
    • Uses PHP for templating
    • No new language to learn
      • DIE SMARTY DIE
    • Powerfull, but sometimes dangerous
  37. TPL Magic
    • page.tpl.php
    • node.tpl.php
    • comment.tpl.php
    • block.tpl.php
    • box.tpl.php
    • etc etc
  38. Learn the variables available to tpl page.tpl.php node.tpl.php $head $styles $scripts $head_title $is_front $footer ... ... $node $links $posted $$page ... ... ...
  39. Override anything themeable theme_pager() phptemplate_pager()
  40. Rule of Thumb is
    • theme('pager');
        • theme-name_pager();
        • theme-engine_pager();
        • theme_pager();
  41. Blocks/Regions are good
    • Blocks are places where chunks of UI GO
    • Called ” regions” in developer language
    • Called ” blocks” user language
  42.  
  43. defining regions
    • function mytheme_regions() {
    • return array(
    • 'left' => t('left sidebar'),
    • 'right' => t('right sidebar'),
    • 'content_top' => t('content top'),
    • 'content_bottom' => t('content bottom'),
    • 'header' => t('header'),
    • 'footer' => t('footer')
    • );
    • }
  44. What we did not cover
    • Upgrade and Maintenance
    • Localization and Internationalization
    • Deployment practices
  45. But you know where to go
    • www.drupal.org
    • http://groups.drupal.org
    • http://lists.drupal.org
    • and off course
    • www.Google.com
  46. Thank You for your time
    • ?
    Mir Nazim Xensoft Labs www.xensoftlabs.com [email_address]

+ manugoel2003manugoel2003, 3 years ago

custom

14696 views, 32 favs, 12 embeds more stats

Mir Nazim - Drupal Best Practices

More info about this document

© All Rights Reserved

Go to text version

  • Total Views 14696
    • 13824 on SlideShare
    • 872 from embeds
  • Comments 3
  • Favorites 32
  • Downloads 867
Most viewed embeds
  • 821 views on http://teknodergi.org
  • 17 views on http://www.mariovarini.it
  • 14 views on http://esteinar.com
  • 5 views on http://www.angrydonuts.com
  • 5 views on http://www.lizr.net

more

All embeds
  • 821 views on http://teknodergi.org
  • 17 views on http://www.mariovarini.it
  • 14 views on http://esteinar.com
  • 5 views on http://www.angrydonuts.com
  • 5 views on http://www.lizr.net
  • 3 views on http://drupalranch.com
  • 2 views on http://longhaily.wordpress.com
  • 1 views on http://feeds.feedburner.com
  • 1 views on http://www.cmshelpers.com
  • 1 views on http://hostsh.com.br
  • 1 views on http://colinlauren07.com
  • 1 views on http://obrita.com

less

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

Cancel
File a copyright complaint
Having problems? Go to our helpdesk?

Categories

Groups / Events