Driving Behavioral Change for Information Management through Data-Driven Gree...
Drupal Modules
1. Well Come to all of you in Drupal (CMS) Session . Developed By. Kunal Guide by: Amit What is Drupal? Drupal is used to build web sites. It’s a highly modular, open source web content management framework Last Updated: October 17 2007
2. Generally there are four types of files in drupal we used. These files extension are 1) .CSS 2) .Info 3) .Install 4) .Module Shortly introduction about above files. 1) .Css :-> Use of css files for change the layout of that perticular module. 2) .Info :-> This file is like the .ini file in windows. the concept of a .info file has been introduced to give Drupal a little more information about your module. 3) .Module :-> Total Functionality about your module. Last Updated: October 17 2007
3. MODULES: Drupal is a truly modular framework. Functionality is included in modules, which can be enabled or disabled (some required modules cannot be disabled). Features are added to a Drupal web site by enabling existing modules, installing modules written by members of the Drupal community,or writing new modules. Drupal makes use of the inversion of control design pattern, in which modular functionality is called by the framework at the appropriate time. These opportunities for modules to do their thing are called hooks. Hooks: Hooks can be thought of as internal Drupal events. They are also called callbacks, though because they are constructed by function naming conventions and not by registering with a listener, they are not truly being called back. Hooks allow modules to “hook into” what is happening in the rest of Drupal.Suppose a user logs into your Drupal web site. At the time the user logs in, Drupal fires the user hook. That means that any function named according to the convention module name plus hook name will be called. Blocks: A block is information that can be enabled or disabled in a specific location on your web site’s template. For example, a block might display the number of current active users on your site.You might have a block containing the most active users, or a list of upcoming events. Blocks are typically placed in a template’s sidebar, header, or footer. Blocks can be set to display on nodes of a certain type, only on the front page, or according to other criteria. Last Updated: October 17 2007
4. .Info :-> This file is like the .ini file in windows. the concept of a .info file has been introduced to give Drupal a little more information about your module.This file is used primarily by the modules administration system for display purposes as well as providing criteria to control activation and deactivation. This file is required for Drupal 5 to recognize the presence of a module.The .info file should have the same name as the .module file and reside in the same directory. For example, if your module is named example.module then your .info file should be named example.info.info files may contain comments. The comment character is the semi-colon and denotes a comment until the end of the line. A comment may begin at any point on the line, thus it is especially important you quote any string that contains a comment. It is typical to place the CVS Id at the top of a .info file using a comment: The .info file can contain the following fields: A) name (Required): The displayed name of your module. It should follow the Drupal 5 capitalization standard: only the first letter of the first word is capitalized Ex. name = "Forum" B) description (Required) : A short, preferably one line description that will tell the administrator what this module does on the module administration page. Remember, overly long descriptions can make this page difficult to work with, so please try to be concise. This field is limited to 255 characters.Ex. description = "Enables threaded discussions about general topics.“ If your .info file's description (or other field) contains characters other than alphanumeric values then you must quote the string. If you need to use " in the string then you need to use the " value to display the " character.For example, this will display correctly: description = "This is my "crazy@email.com" email address“ This is wrong and cause Drupal to display an error when going to the modules menu:description = This is my "crazy@email.com" address <- DO NOT DO THIS Last Updated: October 17 2007 Next Page Next Page
5. C) dependencies (Optional): A space separated list of other modules that your module requires. If these modules are not present, your module can not be enabled. If these modules are present but not enabled, the administrator will be prompted with a list of additional modules to enable and may choose to enable the required modules as well, or cancel at that point. Ex. dependencies = taxonomy comment D) package (Optional): If your module comes with other modules or is meant to be used exclusively with other modules, enter the name of the package here. If left blank, the module will be listed as 'Other'. Ex. package = Views Suggested examples of appropriate items for the package field: 1) Chat 2) Location 3) View 4) Event 5) Video E) version (Optional): Display the version of your modules. Ex. version = 1.1 F) project (packaging use only): Module maintainers should not use this at all. The packaging script on drupal.org will automatically place a string here to identify what project the module came from. This is primarily for the Update status module, so that Drupal installations can monitor versions of installed packages and notify administrators when new versions are available. Last Updated: October 17 2007
6. 3) .Install :-> .install files to do module setup work. A .install file is run the first time a module is enabled, and is used to do setup required by the module. The most common task is creating database tables and fields . .install files are also used to perform updates when a new version of a module needs it. There are three functions in .install files. 1) _install() 2) _Update_x() 3) _Uninstall() Use of _install() function is to install the or create the tables in your database. There are two types of labraries/Packages are used by Drupal. These are MySqli & PgSql Note about already installed modules If the module you are writing the .install file for is already installed then the install/update(s) will not trigger even if you disable/enable it. You need to disable the module and remove its record manually form the system table or include a hook_uninstall function. Last Updated: October 17 2007 Next Page Next Page
7. Syntax For _Install(): function xyz_install() { switch ($GLOBALS['db_type']) { case 'mysql': case 'mysqli': db_query("CREATE TABLE {xyz_data} ( vid int unsigned NOT NULL default '0', field_name varchar(32) NOT NULL default '')); break; case 'pgsql': db_query("CREATE TABLE {xyz_data} ( vid serial CHECK (vid >= 0), field_name varchar(32) NOT NULL default '')); db_query("CREATE INDEX {xyz_data}_field_name_idx ON {xyz_data} (field_name)"); break; } } Last Updated: October 17 2007 Next Page Next Page
8. use of _update_x(): .install files can also include update instructions, which are used through update.php like regular Drupal updates. Each update is placed in a modulename_update_x() function (where x is an incrementing integer). Updates should always increment by 1. Syntax For _update_x(): function example_update_1() { $items = array(); $items[] = update_sql("ALTER TABLE {example} ADD new_column text"); $items[] = update_sql("ALTER TABLE {example} DROP old_column"); return $items; } Last Updated: October 17 2007 Next Page Next Page
9. The _uninstall function is also available in a .install file and gets fired when a module is uninstalled. This function generally includes dropping tables and deleting variables specific to that module. Syntax _uninstall(): function search_uninstall() { db_query('DROP TABLE {xyz_data}'); db_query('DROP TABLE {xyz_index}'); db_query('DROP TABLE {search_total}'); variable_del('minimum_word_size'); variable_del('overlap_cjk'); } Last Updated: October 17 2007 Next Page Next Page
10. In Your .Module files you use the hook’s as a function name. suppose _help is the name of your hook then the name of function should be xyz_help() And the xyz is name of your module. There are certain rules while writing the modules. Last Updated: October 17 2007
11.
12.
Notas del editor
Use this template to create Intranet web pages for your workgroup or project. You can modify the sample content to add your own information, and you can even change the structure of the web site by adding and removing slides. The navigation controls are on the slide master. To change them, on the View menu, point to Master , then choose Slide Master . To add or remove hyperlinks on text or objects, or to change existing hyperlinks, select the text or object, then choose Hyperlink from the Insert menu. When you’re finished customizing, delete these notes to save space in your final HTML files. For more information, ask the Answer Wizard about: The Slide Master Hyperlinks