Saturday, February 28, 2009
Step by Step Guide - Creating New Modules in Drupal
Keywords: Creating a New Module in Drupal, New Module, New Module in Drupal, Drupal New Module, Custom Module, Custom Module in Drupal
Creating a New Custom Module in DRUPAL
Step 1: Create a folder in drupal_root/sites/all/modules/MODULE_NAME
For this you may have to create modules folder in drupal_root/sites/all/ if it doesn't exists
Ex: drupal_root/sites/all/modules/foo
Step 2: Create an information file called "modulename.info" to tell drupal about your module. The file name shall be "modulename.info" and it should be placed in the "drupal_root/sites/all/modules/MODULE_NAME" folder.
Ex: foo.info
Step 3: The information file should have the general information about the new module.
Ex: foo.info shall have the following information
name = FOOdescription = A description of FOOcore = 6.xpackage = Administration
Step 4: Create a module functional file called "modulename.module". The file name shall be "modulename.module" and it should be placed in the "drupal_root/sites/all/modules/MODULE_NAME" folder.
Ex: foo.module
Step 5: Now you have to define the contents, functionality for the new module. That shall be done by creating appropriate functions
Ex: foo.module shall have the following information if you are creating a block module
//File: foo.module//Code Starts//http://kathyravan.blogspot.comfunction foo_block($op='list', $delta=0) {if( $op == "list" ){$block[0]["info"] = t("Foo");return $block;}else{$block['subject'] = 'Foo';$menuString = '';$block['content'] = $menuString;return $block;}}//Code Ends?>
This step will display the menu links.
Step 6: If you want to create any tables while drupal enables your module, you can use hook_enable(), hook_disable() functions in foo.install file.
Ex: A sample .install file (foo.install here) is given below:
//File: foo.module//Code Starts//http://kathyravan.blogspot.comfunction foo_enable( ){drupal_install_schema('helpdesk');}function foo_schema( ){$schema['table_name'] = array('description' => t('Description of the Table.'),'fields' => array('field_id' => array('description' => t('FIELD ID.'),'type' => 'serial','unsigned' => TRUE,'not null' => TRUE),'field_status' => array('description' => t('FieldStatus'),'type' => 'int'),'field_date' => array('description' => t('FieldDate'),'type' => 'int'),),'indexes' => array('ifield_id' => array('field_id'),),'unique keys' => array('ufield_id' => array('field_id'),),'primary key' => array('field_id'),);return $schema;}?>
Note: "foo_enable" function will be called after drupal enabled your module. "drupal_install_schema" will install the tables defined in the module. Same wise "foo_disable" function will be called after drupal disabled your module.
For more information, pls visit
Step 7: Go to "Administer › Site building > Modules", install your module. Check if the table are installed properly.
Step 8: Go to "Administer › Site building > Blocks", select the region of display for your module.
Step 9: Navigate the module.
For more information, pls visit:
- http://api.drupal.org/api/group/hooks
- http://drupal.org/files/drupal_6_core_hooks_cheat_sheet.pdf
- http://drupal.org/node/508
- http://api.drupal.org/api/file/developer/topics/forms_api_reference.html/6
List of Drupal Hook Functions
- custom_url_rewrite_inbound
- custom_url_rewrite_outbound
- hook_access
- hook_actions_delete
- hook_action_info
- hook_action_info_alter
- hook_block
- hook_boot
- hook_comment
- hook_cron
- hook_db_rewrite_sql
- hook_delete
- hook_disable
- hook_elements
- hook_enable
- hook_exit
- hook_file_download
- hook_filter
- hook_filter_tips
- hook_flush_caches
- hook_footer
- hook_form
- hook_forms
- hook_form_alter
- hook_form_FORM_ID_alter
- hook_help
- hook_hook_info
- hook_init
- hook_insert
- hook_install
- hook_link
- hook_link_alter
- hook_load
- hook_locale
- hook_mail
- hook_mail_alter
- hook_menu
- hook_menu_alter
- hook_menu_link_alter
- hook_nodeapi
- hook_node_access_records
- hook_node_grants
- hook_node_info
- hook_node_operations
- hook_node_type
- hook_perm
- hook_ping
- hook_prepare
- hook_profile_alter
- hook_requirements
- hook_schema
- hook_schema_alter
- hook_search
- hook_search_preprocess
- hook_system_info_alter
- hook_taxonomy
- hook_term_path
- hook_theme
- hook_theme_registry_alter
- hook_translated_menu_link_alter
- hook_translation_link_alter
- hook_uninstall
- hook_update
- hook_update_index
- hook_update_last_removed
- hook_update_N
- hook_update_status_alter
- hook_user
- hook_user_operations
- hook_validate
- hook_view
- hook_watchdog
- hook_xmlrpc
- module_hook
- module_implements
- module_invoke
- module_invoke_all
Keywords: Creating a New Module in Drupal, New Module, New Module in Drupal, Drupal New Module, Custom Module, Custom Module in Drupal
Featured Blog Topics:
- MySQLDUMP: Taking Backup of Multiple Databases - http://kathyravan.blogspot.com/2009/02/mysqldump-taking-backup-of-multiple.html
- MySQL LEFT JOIN - http://kathyravan.blogspot.com/2009/01/mysql-left-join.html
- MySQL SQL_CACHE - http://kathyravan.blogspot.com/2008/12/mysql-sqlcache.html
- MySQL Query Caching - http://kathyravan.blogspot.com/2008/12/mysql-query-cache.html
- MySQL Show - http://kathyravan.blogspot.com/2008/12/mysql-show-statements.html
- CSV - MySQL Storage Engine - http://kathyravan.blogspot.com/2008/12/csv-mysql-storage-engine.html
- Blackhole - MySQL Storage Engine - http://kathyravan.blogspot.com/2008/12/blackhole-mysql-storage-engine.html
- Memory - MySQL Storage Engine (Formerly Heap Storage Engine) - http://kathyravan.blogspot.com/2008/12/memory-mysql-storage-engine-formerly.html
- Xml in MySQL - http://kathyravan.blogspot.com/2008/03/xml-in-mysql.html
- Forgot mySQL root Password? - http://kathyravan.blogspot.com/2008/02/forgot-mysql-root-password.html
- Samba - Installation & Configuration - http://kathyravan.blogspot.com/2008/02/samba-installation-configuration.html
- Enabling HTTP Authentication in Apache - http://kathyravan.blogspot.com/2008/08/enabling-http-authentication-in-apache.html
- PHP Function: isFTPFileExists (Searching a FILE in FTP) - http://kathyravan.blogspot.com/2008/12/php-function-isftpfileexists-searching.html
- Shell Scripting & Linux - http://kathyravan.blogspot.com/search/label/Shell%20Scripts
- SBI's New Home Loan Scheme - http://paisamechanic.blogspot.com/2009/02/sbis-special-home-loan-scheme.html
- ATM Locations in Chennai - http://paisamechanic.blogspot.com/search/label/ATM%20Locations%20-%20Chennai
- Deutsche Bank ATM Locations - http://paisamechanic.blogspot.com/search/label/Deutsche%20Bank%20ATM%20Locations
- SBI ATM Locations - http://paisamechanic.blogspot.com/search/label/SBI%20ATM%20Locations
- iMobile - ICICI Bank's New age of Mobile Banking
- HSBC Cheque Drop Box Locations -http://paisamechanic.blogspot.com/search/label/HSBC%20Cheque%20Drop%20Box%20Locations
- CITIBANK Cheque Drop Box Locations -http://paisamechanic.blogspot.com/search/label/Citibank%20Cheque%20Drop%20Box%20Locations
- Standard Chartered Bank Cheque Drop Box Locations - http://paisamechanic.blogspot.com/search/label/Citibank%20Cheque%20Drop%20Box%20Locations
- IFSC Code Definition - http://paisamechanic.blogspot.com/2008/12/ifsc-code-definition.html
- IFSC Codes of All Banks - http://paisamechanic.blogspot.com/2008/12/ifsc-codes-of-indian-banks.html
- IFSC Codes of Deutsche Bank - http://paisamechanic.blogspot.com/2009/01/ifsc-codes-of-deutsche-bank.html
- IFSC Codes of Syndicate Bank - http://paisamechanic.blogspot.com/2009/01/ifsc-codes-of-syndicate-bank.html
- IFSC Codes of Andhra Bank - http://paisamechanic.blogspot.com/search/label/IFSC%20Codes%20-%20Andhra%20Banks
- OneView HDFC Bank - All in One Internet Banking -http://paisamechanic.blogspot.com/2008/12/oneview-hdfc-bank-all-in-one-internet.html
- EMI Calculator - http://paisamechanic.blogspot.com/2008/12/emi-calculator.html
- Standard Chartered Bank Cheque Drop Box Locations Chennai -http://paisamechanic.blogspot.com/2008/12/standard-chartered-bank-cheque-drop-box.html
- Standard Chartered Bank Cheque Drop Box Locations Bangalore -http://paisamechanic.blogspot.com/2008/12/standard-chartered-bank-cheque-drop-box.html
- Reliance Guarantee Return Plan- http://paisamechanic.blogspot.com/2008/12/reliance-guarantee-return-plan.html
- SBI NEFT Fund Transfer - http://paisamechanic.blogspot.com/2008/12/sbi-neft-fund-transfer.html
- IFSC Codes of Indian Banks - http://paisamechanic.blogspot.com/2008/12/ifsc-codes-of-indian-banks.html
- Mobile Showroom Locations - http://paisamechanic.blogspot.com
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment