Sam M. K. FOLI-AWLI (mawusee.foli@azri.

biz)
S am M . K . F OL I -A W L I

Plan

I- Drupal 7 Architecture

II- How do I develop with drupal 7

III- How do I upgrade from drupal 5.7 to drupal 7.0 Beta

IV- References

2/23

S am M . K . F OL I -A W L I

Drupal 5.7 vs Drupal 7.0Beta / Architecture

The main architecture (contents are nodes, use of hooks) is still the same (1). [What has not changed] - Node - Hooks - Module - Menu - Localisation - Themes - Profiling (how to install different websites) - Users with permissions

(1) Consult  Pro Drupal Developement, John K. VanDyk and Matt Westgate 2007 for the technology stack,
3/23
S am M . K . F OL I -A W L I

Drupal 5.7 vs Drupal 7.0Beta / Architecture

[Some changes] . More Core optional modules like actions, triggers  . Required modules are no more displayed (node, block), . Sqlite is supported . Drag and drop more used (block, menus,etc.) (UI changes) . The "files" is supposed to be in /root/sites/default/files (File architecture) . One folder "expert" added in the profiles folder .  A "code registry" which is a set of database tables holding all of the functions in all of the modules, allowing files to be lazy-loaded. This requires changes to your .info files

4/23

S am M . K . F OL I -A W L I

Drupal 5.7 vs Drupal 7.0Beta / Architecture

[Some more changes] . Modules dependencies managed better when deleting, adding a module . Performance improvements: the registry now keeps a record of all modules that implement a given hook, and caches registry lookup . the installation is more convivial . The unit test tool "Simpletest" is now integrated by default

PS: some changes are done since the version Drupal 6
5/23
S am M . K . F OL I -A W L I

Drupal 5.7 vs Drupal 7.0Beta / Work with Drupal 7

[Themes] .info file (name,description,core,version,engine,regions[ ],base theme, features[ ] ,stylesheets,scripts,php) . Use "tpl.php" files or functions for theming (node-view.tpl.php, node-edit.tpl.php,etc.
Example : block-user-1.tpl.php would be used for the default user navigation.

. theme variables : $left, $right,$main_menu, $secondary_menu,etc. . Use preprocess functions (garland_preprocess_page => page.tpl.php, whitejazz_preprocess_forums for forums.tpl.php) to avoid coding in tpl files . drupal_add_css and drupal_add_js overrides modules or core css and js files when the new file has the same name. . Use "Zen" theme to start from scratch
6/23
S am M . K . F OL I -A W L I

Drupal 5.7 vs Drupal 7.0Beta / Work with Drupal 7

7/23

S am M . K . F OL I -A W L I

Drupal 5.7 vs Drupal 7.0Beta / Work with Drupal 7

[Modules] .info file (name, description, dependencies[ ], files, version, package) .hook _perm .hook_install/hook_uninstall (drupal_install_schema/drupal_uninstall_schema) .hook_help .hook_menu (new Menu type MENU_ACCESS_DENIED,MENU_FOUND) * hook_menu_alter : modify menu callbacks * hook_schema : define the schema of the table of the module * hook_schema_alter : database modification * hook_watchdog : reports (logs) * hook_block is no more used but compatible
8/23
S am M . K . F OL I -A W L I

Drupal 5.7 vs Drupal 7.0Beta / Work with Drupal 7

[Javascript / CSS] .script.js and script.css by default loaded and in the theme directory .Drupal.t : for translation expressions in javascript code .Drupal_add_js : inline code, add js file, add settings data .Drupal_add_css : add a css file .Drupal_get_js : render the header javascript code (<script>...</script>) .Drupal_get_css : render the header css code (<link .../>) .Drupal_js_alter : alter the javascript files before render

9/23

S am M . K . F OL I -A W L I

Drupal 5.7 vs Drupal 7.0Beta / Work with Drupal 7

[Coding standard]
# Writing code that comments itself # The necessity of documentation # Naming your functions, files, variables # Using global variables # Making your modules extensible # Avoid creating code that already exists : use the API documentation

{Magic tools !!} . Coder module for code review . Devel module for debugging (tracing, theme_debugging, dprint_r,etc.)
10/23
S am M . K . F OL I -A W L I

Drupal 5.7 vs Drupal 7.0Beta / Work with Drupal 7

[Some doubts...]
1. Override in Drupal ... - module weights - hooks - callbacks 2- Use of Ajax in Drupal ... { + there is javascript function call or event + variables or code is executed + a path is called + drupal[php_code] calls a drupal_add_json(send a json format data) } 3. How to use javascript effects or form validations ? - Effects are functions or plugins available for a jquery object "jq_object.effect(params)". - Javascript code or ajax call (form validation) 4. Code registry ? - 2 tables registry (function, type, suffix,weight,module,filename) and registry_files ) - cache_registry
11/23
S am M . K . F OL I -A W L I

Drupal 5.7 vs Drupal 7.0Beta / Work with Drupal 7

[Some doubts – Ajax sample code]
// Implementation of hook_menu(). function myModule_menu() {   $items['photos/get/photos'] = array( 'page callback' => 'mymodule_get_photos_ajax',     'type' => MENU_CALLBACK, 'access arguments' => array('access content'),   );   return $items; }  function mymodule_get_photos_ajax($nid) { // returns the filepath of my photo   $photo = mymodule_get_photo($nid);   $image = theme('image', $photo);   print drupal_to_js(array( 'image' => $imagefile, ) ); }

12/23

S am M . K . F OL I -A W L I

Drupal 5.7 vs Drupal 7.0Beta / Work with Drupal 7

[Some doubts - Ajax]
Drupal.behaviors.myModule = function() {   $('a.photo_button:not(.mymodule-processed)', context).addClass('mymodule-processed')   .bind('click', function(){     $.get('/photos/get/photos/'+ parseInt(this.id, 10), null, imageDetails);     return false;   }); } var imageDetails = function(data) {   var result = Drupal.parseJson(data);   $('div.field-type-image div.field-item').html(result['image']); }

13/23

S am M . K . F OL I -A W L I

Drupal 5.7 vs Drupal 7.0Beta / Upgrade

[Upgrade – basic steps] - Evaluate the upgrade cost (are contributed modules used compatible with new version, custom modules upgrade, etc.) - Backup your existing site and database - Download and install the new drupal instance - Check the UPGRADE.txt file in the new drupal folder - Upload the new instance - run the update.php file to update the database

14/23

S am M . K . F OL I -A W L I

Drupal 5.7 vs Drupal 7.0Beta / Upgrade

[Upgrade : Case of www.azri.in]

15/23

S am M . K . F OL I -A W L I

Drupal 5.7 vs Drupal 7.0Beta / Upgrade

[Upgrade : Case of azri.in] Step 1 - Backup database and code
- Install drupal7 - Add azri theme (whitejazz) - Replace all theme variables ($primary_links, etc.) - Redefining theme regions in info files - Modifying the Css file (the files default folder is now in sites/default/files) to display background images and styles

16/23

S am M . K . F OL I -A W L I

Drupal 5.7 vs Drupal 7.0Beta / Upgrade

[Upgrade : Case of azri.in] Step 2 For a menu link ... - Add his node - Add his alias if needed - Putting back it's blocks (proceed link by link) Full Html filter for the block content)

17/23

S am M . K . F OL I -A W L I

Drupal 5.7 vs Drupal 7.0Beta / Upgrade

Step 3

Identify modules ... “blocktheme module” - Update the info file - Install the module - Update the code - Update the template file

* the “panels” module is installed but not used.

18/23

S am M . K . F OL I -A W L I

Drupal 5.7 vs Drupal 7.0Beta / Upgrade

function whitejazz_block($block) { $template_path = drupal_get_path('theme', 'whitejazz')."/"; if (module_exists('blocktheme')) { $custom_theme = blocktheme_get_theme($block); $custom_theme = (is_array($custom_theme) && (count($custom_theme) >0)) ? $custom_theme[0] : $custom_theme; } //If no custom_theme is found the default "block.tpl.php" file will be used $custom_theme = ($custom_theme) ? $custom_theme : "block"; return theme_render_template($template_path.$custom_theme.".tpl.php",array('block' => $block)); }

19/23

S am M . K . F OL I -A W L I

Drupal 5.7 vs Drupal 7.0Beta / Upgrade

[For this particular upgrade] - Few nodes - Most nodes should be displayed without their titles - Many blocks - Update the blocktheme module - Display block themes (tpl.php file)

20/23

S am M . K . F OL I -A W L I

Drupal 5.7 vs Drupal 7.0Beta / Questions

[References] http://drupal.org/update/modules (Update modules) http://api.drupal.org/api/7 http://drupal.org/node/190815 http://drupal.org/node/156281 http://drupal.org/upgrade/ (Drupal 7 API) (Core templates and suggestions) (Drupal7 release note) (Drupal upgradation)

Pro Drupal Developement, John K. VanDyk and Matt Westgate 2007 for the technology stack,

21/23

S am M . K . F OL I -A W L I

Drupal 5.7 vs Drupal 7.0Beta / Questions

Questions ?
Questions ?
Questions ?
Questions ?
Questions ?

T hank s :-)

22/23

S am M . K . F OL I -A W L I

Drupal 5.7 vs Drupal 7.0Beta

[Credits]

AZRI Solutions (www.azri.in)

Drupal Community www.drupal.org

23/23

S am M . K . F OL I -A W L I

Sign up to vote on this title
UsefulNot useful