Using Spaces
  Stijn De Meyere
Topics
• Spaces in general
• Space types
• Spaces + PURL
• Space controllers
• Features integration
• Use cases

                            2
What is spaces?
http://drupal.org/project/spaces




                                   3
From the project page

Spaces is an API module intended to make
 configuration options generally avaliable
only at the sitewide level to be configurable
and overridden by individual "spaces" on a
                 Drupal site.




                                               4
My description


 Spaces is an API module that introduces
context to your site, effectively allowing you
      to load different configuration.




                                                 5
What does this mean?
• Abstract API
• No real UI
• For developers




                           6
What’s it good for?
• Create site sections
• Set up multiple sites with or without shared content
• Create private/public groups
• Give editor/admin rights to certain users on certain
  parts of the site

• Enable different features based on the active
  space

• ...
                                                         7
The Magic



spaces_load('space_type', 'id')->activate();




                                           8
The Magic



$space = spaces_get_space();




                               9
The Magic



$space->deactivate();




                        10
Space types



              11
Space types
• Trigger (not as in actions)
• A property, anything you want
• Plugin based (ctools)
• Extend base types




                                  12
Provided space types
• Organic Groups
• Taxonomy
• User




                           13
Spaces + PURL
http://drupal.org/project/purl




                                 14
PURL
                 Persistent URL




It is meant to be a helper for other modules
  interested in using elements of the page
    request to sustain information between
  pages without using a SESSION or other
                hackish means.




                                               15
PURL Providers
• Path prefixes: http://example.com/foo/node/5
• Path prefix pairs: http://example.com/group/1/node/5
• Query string: http://example.com/node/5?group=1
• Domains: http://example.com/node/5
• Subdomains: http://foo.example.com/node/5
• Path Extensions: http://example.com/node/5.csv
  (detection only, no rewriting)

• HTTP User Agent: Mozilla/5.0 (iPhone; U; CPU like
  Mac OS X; en) (detection only, no rewriting)
                                                        16
PURL
• Rewrite link
  • hook_url_inbound_alter()
  • hook_url_outbound_alter()




                                17
The Magic

$options = array(
 'purl' => array(
   'provider' => 'purl_provider', 
   'id' => 5
 ),
);



                                     18
The Magic


$options = array(
 'purl' => FALSE,
);




                     19
Spaces + PURL
• extend space_type_purl
• Keeps a space alive




                           20
Space controllers



                    21
Space controllers


Provides a way to manage configuration for
               each space.




                                            22
Space controllers


Configuration that lives, or can live, in code can
               be overruled.

    (or basically: anything that comes with a hook or a
        drupal_alter can become space dependent)




                                                          23
Configuration stack


   site > preset > space




                           24
Configuration stack


     site > preset > space
 site > preset > space > user




                                25
Implemented controllers
• Variable
• Context

• (menu reorder)




                            26
Spaces + Features



                    27
Spaces + Features
• A special controller to manage features in a
 space

• Disable / Enable a feature without touching the
 feature module

• Provide configuration for your feature



                                                    28
The Magic


spaces[types] = "all"
spaces[types] = "og"
spaces[types] = "user"




                         29
Spaces Dashboard


Provides a feature to create/configure a
        dashboard per space.




                                          30
Obligatory screenshot
                        31
Use Cases



            32
Open Atrium
http://openatrium.com/
                         33
Belgian Beer Weekend
  http://belgianbeerweekend.jp

                                 34
Belgian Beer Weekend
  http://belgianbeerweekend.jp
                                 35
Belgian Beer Cafe
http://www.belgianbeercafe.com/
                                  36
Belgian Beer Cafe
http://www.belgianbeercafe.com/
                                  37
Mystery project
• Launch with 200+ microsites
• Grow up to 800+ microsites
• Lots of shared content (± 30 pages/microsite)
• Authors & editors per microsite, top-level
 moderators

• Custom entity
• Whitelabling
                                                  38
@stijndm
freelance Drupal dev




                       39
Feedback & follow-up:
http://drupalcampgent.be/feedback

Using spaces (Drupal)

Editor's Notes

  • #2 \n
  • #3 \n
  • #4 \n
  • #5 \n
  • #6 \n
  • #7 \n
  • #8 \n
  • #9 \n
  • #10 \n
  • #11 \n
  • #12 \n
  • #13 \n
  • #14 \n
  • #15 \n
  • #16 \n
  • #17 \n
  • #18 \n
  • #19 \n
  • #20 Menu settings for the backend\n
  • #21 \n
  • #22 \n
  • #23 \n
  • #24 \n
  • #25 Space overrules preset, overrules site\n
  • #26 Add your own stack, ie: let the user have some control over settings\n
  • #27 Whenever a space is active, these controllers come in to action and save the settings for that sapce\nEven in the backend. \n
  • #28 \n
  • #29 \n
  • #30 \n
  • #31 \n
  • #32 The space settings form (as seen in Open Atrium)\n
  • #33 \n
  • #34 It all started with Development Seed and their personal intranet, which led to Open Atrium\nDrupal 6\n
  • #35 Drupal 7\nSpaces + taxonomy\nTweaks to allow same page in multiple spaces\nBuilt to last a couple of years\nNow with a custom path prefix city + year\nUsed to be domain + prefix\nEach city has it’s own mini site, whenever they are ready with the content they can enable the feature for that mini site\n
  • #36 Left: Nagoya, beer menu is published, different blocks (same context), different sponsors (same feature)\nRight: Tokyo, beers are currently unknown, feature is disabled\n
  • #37 Drupal 6\nSpaces + Organic groups\n
  • #38 Each cafe is a different space \nCafe owner can manage cafe profile + beers, menu\nAdd staff to the cafe > linked to schooling platform\n
  • #39 Drupal 7\nCustom entity with 2 types -> profile acts as preset, microsite acts as space\nCustom menu controller\nTheme selection\n
  • #40 \n
  • #41 \n