Probably everybody have come across with ready-to-use site packages on Drupal where after installation you get a ready site with the set of necessary modules, personal theme and so on. There are many such packages, among which Open Atrium, Drupal Commons and others. I’m sure the question appeared: “How was it realized?” or “How can it be done?” The answer to this question is Drupal Install Profile. So how can a personal install profile be created? Generally install profiles are created on the basis of the existed site.
Step 1. Preparation of files.
Create “modules” folder, “contrib” folder in it into which all the modules necessary for work are copied.
“themes” folder is created into which a folder with our themes is put, for example, acquia_prosper, and .tpl.php sets and .js and .css files created in the process of site development. To include several special elements of site into a package, such as views, content type, menu, roles, access rights and others, Features module is used. Created features are put into “features” folder and added to “modules” folder.
Note: At the moment Features module doesn’t transfer taxonomy dictionaries and terms into them, maybe it will be done in the following versions of module, that’s why it should be done manually. It’ll be described further.
We’ll get the following structure:
myprofile
- modules
- contrib
- features
- themes
Step 2. Creation of .profile file
This file is the “brain” of our profile; it manages the site installation process.
Note: At this stage of site work function t() doesn’t function, that’s why its equivalent st () is used.
2.1. myprofile.profile is created.
2.2._profile_modules().
Function myprofile_profile_modules () is formed. In this function the modules are described which should be turned on after installation.
// $Id$ // indicate dictionary taxonomy id define('MYPROFILE_NEWS_VOCAB_ID', 1); // indicate topic title define('MYPROFILE_ACQUIA_THEME', 'acquia_prosper'); define('MYPROFILE_FUSION_CORE', 'fusion_core'); /** * Returns array of modules which will be turned on after profile installation */ function myprofile_profile_modules() { $modules = array( // Default Drupal modules. 'color', 'comment', 'dblog', 'help', 'menu', 'path', 'taxonomy', //ADMINISTRATION 'admin', 'admin_menu', //CCK 'content', 'text', 'ctools', 'content_permissions', 'fieldgroup', 'filefield', 'optionwidgets', 'nodereference', 'userreference', //FILEFIELD PATHS 'filefield_paths', //IMAGECACHE 'imageapi', 'imageapi_gd', 'imagecache', 'imagecache_ui', 'imagecache_customactions', //TOKEN 'token', //VIEWS 'views', 'views_bulk_operations', 'viewscarousel', 'views_export', 'views_or', 'views_slideshow', 'views_ui', //META TAGS 'nodewords', 'nodewords_basic', 'nodewords_extra', 'nodewords_verification_tags', //USER INTERFACE 'imce', 'wysiwyg', 'jquery_ui', 'jquery_update', 'dialog','vertical_tabs', 'imce_wysiwyg', //SKINR 'skinr', 'skinr_ui', //OTHER 'better_formats', 'globalredirect', 'no_anon', 'pathauto', 'url_alter', 'subpath_alias', 'token_actions', 'transliteration', 'vertical_tabs', //UBERCART 'ca', 'uc_order', 'uc_store', 'uc_product', 'uc_cart', 'uc_payment', 'uc_reports', 'uc_shipping', 'uc_product_power_tools', 'uc_stock', //XML SITEMAP 'xmlsitemap', 'xmlsitemap_engines', 'xmlsitemap_menu', 'xmlsitemap_node' ); return $modules; }
Note: Modules which “depend on” other ones should be indicated after those that they depend on. There are also problems when url_alter module is turned on. The decision can be found here.
2.3. _profile_details().
Profile description which will be shown on profile installation screen.
/** @return * array with keys "name" and "description", describing the given profile, * and additional "language", to redefine language for a profile */ function myprofile_profile_details() { $description = st('Select this profile to install the My custom profile.'); return array( 'name' => 'My profile', 'description' => $description, ); }
Note: Modules which “depend on” other ones should be indicated after those that they depend on. There are also problems when url_alter module is turned on. The decision can be found here.