Install Drupal modules programmatically
This is how you can install Drupal modules programmatically
<?php
function mymodule_install_features() {
$items = array();
drupal_install_modules(array( 'mymodule_cck', 'mymodule_views', 'mymodule_nodetypes'));
drupal_set_message("Installed features for Mymodule");
drupal_flush_all_caches();
return $items;
}
?>
And taxonomy
<?php
install_include(array('taxonomy'));
$props = array('module' => 'taxonomy', 'multiple' => 1);
install_taxonomy_add_vocabulary('Plants', array('article' => 'article'), $props);
$props = array('module' => 'taxonomy');
install_taxonomy_add_vocabulary('Asia', array('article' => 'article'), $props);
install_taxonomy_add_vocabulary('Europe', array('article' => 'article'), $props);
?>
Content types
<?php
install_include(array('node'));
$props = array(
'description' => 'Plant articles',
);
install_create_content_type('plant', 'Plant articles', $props);
$props = array(
'description' => 'Article',
);
install_create_content_type('article', 'Article', $props);
?>
Permissions and roles
<?php
install_include(array('user'));
$moderator_rid = install_add_role('moderator');
$contributor_rid = install_add_role('contributor');
$developer_rid = install_add_role('developer');
install_add_permissions($contributor_rid, array('post comments', 'post comments without approval'));
install_add_permissions($moderator_rid, array('administer comments', 'administer users'));
?>
Take a look at How to add an Vocabulary in an install file, http://www.zimplicit.se/knowledge/how-add-vocabulary-install-file
Knowledge keywords: