Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Using Features

1,876 views

Published on

Presentation on Features from Drupalcamp Timisoara 2010.

Published in: Technology
  • Be the first to comment

Using Features

  1. 1. Using Features <ul><li>Drupalcamp Timisoara </li></ul><ul><li>Alexandru Badiu </li></ul><ul><li>Iunie 2010 </li></ul>
  2. 2. This might have happened to you <ul><li>The dev – staging – production issue </li></ul><ul><li>You build the site </li></ul><ul><li>Client wants new stuff </li></ul><ul><li>You build it on dev, passes staging </li></ul><ul><li>Replicate on live site </li></ul><ul><li>Write update functions, manual exporting of views, cck </li></ul>Using Features – Alexandru Badiu
  3. 3. This might have happened to you <ul><li>The “I’ve done this before” issue </li></ul><ul><li>You build some feature for client A </li></ul><ul><li>Along comes client B who wants the same thing </li></ul><ul><li>Take code, exported views, cck, push to dev </li></ul><ul><li>Work </li></ul><ul><li>Replicate on prod </li></ul>Using Features – Alexandru Badiu
  4. 4. This might have happened to you <ul><li>The “Is there anyone editing file x.module?” issue </li></ul><ul><li>You work on a large project </li></ul><ul><li>Each dev pushes code to a repository </li></ul><ul><li>What about database changes? </li></ul><ul><li>Export views, cck and push them as well </li></ul><ul><li>Make sure each dev imports stuff after each update </li></ul>Using Features – Alexandru Badiu
  5. 5. This might have happened to you <ul><li>The “What the f**k do I do now?” issue </li></ul><ul><li>Drupal is hard for beginners </li></ul><ul><li>Lots of modules </li></ul><ul><li>Building a feature requires multiple modules usually and some knowledge about them </li></ul><ul><li>Drupal recipes are good </li></ul>Using Features – Alexandru Badiu
  6. 6. Do you see a pattern? <ul><li>Wouldn’t it be nice if you had a repository of “modules” that create functionality a little bit more than “list all blog posts” or “have a block with latest promoted posts in category A”? </li></ul><ul><li>Learn the open source way </li></ul><ul><li>Instant gratification </li></ul><ul><li>Uuuu, this is cool </li></ul>Using Features – Alexandru Badiu
  7. 7. Do you see a pattern? <ul><li>Wouldn’t it be nice if you could avoid all the manual exporting and importing of new features / changes and just package functionality in a “module” that can be updated? </li></ul><ul><li>Modules are code, code can be put into versioning control </li></ul><ul><li>Database changes can’t (easily) </li></ul>Using Features – Alexandru Badiu
  8. 8. Do you see a pattern? <ul><li>Just click to generate a new version of the “module“ </li></ul><ul><li>Check in, others check out, update is done </li></ul><ul><li>Less wrinkles and teeth grinding </li></ul>Using Features – Alexandru Badiu
  9. 9. So what is the problem? <ul><li>This is not necessarily a Drupal only problem </li></ul><ul><li>It’s the nature of web development and the way we do it </li></ul><ul><li>Coding != Site building </li></ul><ul><li>If only products of site building could be exported… </li></ul><ul><li>Oh wait </li></ul>Using Features – Alexandru Badiu
  10. 10. So what is the problem? Using Features – Alexandru Badiu
  11. 11. Exportables <ul><li>Exportables are ways of, well, exporting things from Drupal into code bits </li></ul><ul><li>Pioneered by Views, CCK is also using this </li></ul><ul><li>Imagecache, Spaces, Context, Strongarm </li></ul><ul><li>Is this enough? </li></ul><ul><li>No, replication is still a… not a piece of cake </li></ul><ul><li>Lots of missing modules (like taxonomy) </li></ul>Using Features – Alexandru Badiu
  12. 12. Modular design <ul><li>It can also help if your site functionality is broken into a modular design </li></ul><ul><li>Like maybe prefixing presets and views with blog_ or joblistings_ </li></ul><ul><li>Or use image_blog_medium rather than image_blog_300x50 </li></ul><ul><li>Or have site_blog.module and site_listings.module rather than that gigantic site.module </li></ul><ul><li>These are nice first steps </li></ul>Using Features – Alexandru Badiu
  13. 13. Modular design <ul><li>What about blocks? </li></ul><ul><li>Block visibility: php code or list of pages? Both? Complex conditions? </li></ul><ul><li>What about menus? </li></ul><ul><li>I want this menu to appear when you’re on a blog post but I want this other menu to appear on listings. </li></ul><ul><li>Sitewide conditions: this should appear only if none of the conditions for the other “sections” are met </li></ul><ul><li>Add more and more sections </li></ul>Using Features – Alexandru Badiu
  14. 14. The Context module <ul><li>Built by Development Seed </li></ul><ul><li>You create sections for your site </li></ul><ul><li>They are triggered by various conditions </li></ul><ul><li>They enable blocks, activate menus </li></ul><ul><li>They can be global </li></ul><ul><li>They can act as failbacks </li></ul><ul><li>They stack </li></ul><ul><li>http://drupal.org/project/context </li></ul>Using Features – Alexandru Badiu
  15. 15. Almost there <ul><li>We can organize “visual” bits and pieces of our site using contexts </li></ul><ul><li>We can use the same organization to name the products of our various site building tools </li></ul><ul><li>We can follow a modular approach when developing our modules </li></ul><ul><li>If only we could package all these changes into a module. </li></ul><ul><li>Can it also be easy too? </li></ul>Using Features – Alexandru Badiu
  16. 16. The Features module <ul><li>The Features module does exactly that </li></ul><ul><li>It takes different clues as to what you want to package </li></ul><ul><li>There’s the manual way too (it’s not perfect) </li></ul><ul><li>It exports automatically whatever it can (not all modules use exportables  ) </li></ul><ul><li>It adds it’s magic </li></ul><ul><li>Generates a “feature” which is actually a module </li></ul>Using Features – Alexandru Badiu
  17. 17. The Features module <ul><li>The module contains all the necessary bits and pieces about your views, content types, presets etc </li></ul><ul><li>Contains code to activate them (create or update them) and deactivate them </li></ul><ul><li>Knows about dependencies so it won’t break the site </li></ul><ul><li>It’s a module so you can hack away </li></ul><ul><li>Once you add more stuff: click click => new version of the module </li></ul><ul><li>Install module on other site, presto </li></ul>Using Features – Alexandru Badiu
  18. 18. The Features module <ul><li>It doesn’t use update functions </li></ul><ul><li>But you can write your own </li></ul><ul><li>Doesn’t script site building, uses exportables </li></ul><ul><li>This means that lots of modules don’t work </li></ul><ul><li>Webform: uses actual content rather than content types </li></ul><ul><li>Taxonomy: doesn’t use a machine name but numeric id’s </li></ul>Using Features – Alexandru Badiu
  19. 19. Share <ul><li>A feature can be installed on any other site that has the required modules </li></ul><ul><li>You can put it on d.org </li></ul><ul><li>Features server: repository of features </li></ul><ul><li>Internal or external </li></ul><ul><li>Get notified of updates </li></ul>Using Features – Alexandru Badiu
  20. 20. Basic usage <ul><li>Simple demo </li></ul><ul><ul><li>We are going to build a blog feature </li></ul></ul><ul><ul><li>Use a context to “group” it </li></ul></ul><ul><ul><li>Create a content type for it </li></ul></ul><ul><ul><li>Make it use a vocabulary </li></ul></ul><ul><ul><li>Create a listing and a block using views </li></ul></ul><ul><ul><li>Package it using Features </li></ul></ul><ul><ul><li>Deploy it on another site </li></ul></ul>Using Features – Alexandru Badiu
  21. 21. More advanced stuff <ul><li>A bit about a more complex usage scenario </li></ul><ul><ul><li>CNP – Creative Network Platform </li></ul></ul><ul><ul><li>Built by Raw Nerve and OpenlyConnected last year </li></ul></ul><ul><ul><li>Powers three sites: http://londondesignfestival.com/ , http://www.creativeislanduk.com/ and the “never made it” beta of Project: Groundwork </li></ul></ul><ul><ul><li>Team scattered in 6 cities </li></ul></ul><ul><ul><li>Build the first site using features, reuse for all other sites and just change small things and do the theme </li></ul></ul><ul><ul><li>Be careful with the extra things you add in a feature’s code: use drush </li></ul></ul>Using Features – Alexandru Badiu
  22. 22. Even more advanced stuff <ul><li>Almost nothing about the hardcore usage </li></ul><ul><ul><li>The next step: the Spaces module </li></ul></ul><ul><ul><li>Again, Development Seed </li></ul></ul><ul><ul><li>Makes a Drupal site act like multiple sites </li></ul></ul><ul><ul><li>Makes features spaces aware: selective enabling of features on a per group basis </li></ul></ul>Using Features – Alexandru Badiu
  23. 23. Resources <ul><li>http://drupal.org/project/features </li></ul><ul><li>http://drupal.org/node/580026 </li></ul><ul><li>http://drupal.org/project/context </li></ul><ul><li>http://drupal.org/project/spaces </li></ul><ul><li>http://groups.drupal.org/packaging-deployment </li></ul><ul><li>http://developmentseed.org/tags/features </li></ul>Using Features – Alexandru Badiu
  24. 24. Alexandru Badiu Thanks <ul><li>[email_address] </li></ul><ul><li>http://plan9fromweb.com </li></ul><ul><li>http://corporate.adulmec.com </li></ul>

×