Building and Deployment of
Drupal sites with Features and Context
by Svilen Sabevat DrupalCamp Sofia 2011on 23 Jan 2011
We love Drupal because Drupal is robust content management system with
great possibilities that can be used to build almost any kind of website
Drupal has a lot of contributed modules to solve problems and to make different desirable solutions
Drupal has great community all over the world
Frequent tasks create content types and CCK fields create taxonomy vocabularies and terms configure imagecache presets create views to display content build panel pages to position content setup user roles and permissions
Problems Business decisions and configuration settings are
in database Making changes and deployment is time
consuming and error prone process No history log of modifications No organization of site’s features
The Solution A module that would automatically package any
of your site’s features into another module for you to download and share
Features module Features is a Drupal module created by
Development Seed
Features provides a UI and API for taking different site building components from modules with exportables and bundling them together in a single feature module
http://drupal.org/project/features
Features moves configuration from the database to code
Features lets you organize your project
Features lets you control your site’s features with version-controlled systems
Features makes deployment easy
Features lets you share and reuse configurations
What can be exported? Content types CCK fields Views Imagecache presets Ctools (Panels, Variables, Feeds, Data and more) User roles and permissions Menus and menu links Input formats Context
What is difficult to be exported?
Vocabularies Nodequeues Nodes, Terms and Users *
because Features hates sequential IDs
http://drupal.org/project/features_extrahttp://drupal.org/project/uuid_features
Let’s see Features in demo
Think how to organize Separate features by context
(News, Events, Gallery, Videos, Homepage) Separate features by components
(Imagecache, Views, Panels, Permissions, Menus) Make reusable features Don’t share same CCK field with different
configurations between two features Be careful with dependencies
Deployment process Build on development site locally
Show staging site to the client
Update the result on production site
Workflow of Deployment Process in team
Darin create a content type and the CCK fields on his local development site. He package everything as a feature and commit that module to the repository
I update my repository, install the feature and automatically receive the configuration that Darin created. I add couple views and imagecache presets and attach them to that feature.
Darin update and make adjustments on fields. He commits the changes.
I update and overwrite styles for views and commit again.
Jens update his repository and fixes our configurations. He commits the changes to our staging site and install the feature. If the client is satisfied he can upload the feature to production site.
The advantages Every feature modification is logged
Features makes deployment easy
Features makes reuse of configuration possible
Changes by clients will be logged and can be easily reverted.
Component statesFeature keeps tracks on following things to define its component states:
Current configuration in code Change of current configuration in code with svn
update Configuration represented in database
Features determines components in following states:Default, Overridden, Needs Review, Rebuilding, Conflict
Drush and Featuresdrush features List all the available features on your site
and their status.
drush features-export [feature name] [component list]
Write a new feature in code containing the components listed.
drush features-update [feature name]
Update the code of an existing feature to include any overrides from your database
drush features-revert [feature name]
Revert a feature in your site's database to the state described in your code
drush features-diff [feature name]
Show a diff between a feature's database components and those in code.
Kit
A set of guidelines that facilitates building compatible and interoperable Feature modules.
KIT Feature Specification (kitf 1.0-draft) KIT Theme Specification (kitt 1.0-draft)
http://drupal.org/project/kit
Context module Context allows you to manage contextual
conditions and reactions for portions of your site.
Conditions are set of rules that are checked during page load to see what context is active.
Any reactions that are associated with active contexts are then fired.
Think for context like sections of the site
Basic “News” context Conditions
Menu item “News” is clicked Node type “News” is opened
Reactions Menu item “News” is active News categories block in right sidebar
Define context layoutslayouts[columns][name] = "Columns"layouts[columns][description] = "Three column
layout."layouts[columns][stylesheet] = "layout-columns.css"layouts[columns][template] = "layout-columns"layouts[columns][regions][] = "header"layouts[columns][regions][] = "content"layouts[columns][regions][] = "left"layouts[columns][regions][] = "right"
Drupal ThursdaysFor you that want to learn advanced Drupal from
the developers and themers in Propeople
Location: Sofia, Pirin 40A streetDate: Every Thursday from ~19.30
More info: http://groups.drupal.org/bulgaria
We’re hiring Team Lead / Senior PHP developer PHP / Drupal developers Senior HTML developer
Interested? Talk with Welin or Rumen
Thank You!Any questions?
Top Related