| | 1 | |
| | 2 | Context layouts |
| | 3 | --------------- |
| | 4 | Context layouts provides a formalized way for themes to declare and switch |
| | 5 | between page templates using Context. It is a continuation of an old Drupal |
| | 6 | themer's trick to switch to something besides the standard `page.tpl.php` file |
| | 7 | for a variety of special-case pages like the site frontpage, login page, admin |
| | 8 | section, etc. |
| | 9 | |
| | 10 | |
| | 11 | Requirements |
| | 12 | ------------ |
| | 13 | In order to use context layouts, your site must meet a few conditions: |
| | 14 | |
| | 15 | - Context and Context layouts modules are enabled (`admin/build/modules`). |
| | 16 | - You are using a theme which provides and has declared multiple layouts. (See |
| | 17 | "Example themes" for themes you can try.) |
| | 18 | |
| | 19 | |
| | 20 | Basic usage |
| | 21 | ----------- |
| | 22 | Once you have layouts enabled, you can have a context trigger the usage of a |
| | 23 | particular layout in either the admin interface (`admin/build/context`) or |
| | 24 | inline context editor. Different layouts may have fewer or greater regions than |
| | 25 | the default page template, so adjust your blocks accordingly. |
| | 26 | |
| | 27 | |
| | 28 | Supporting context layouts in your theme |
| | 29 | ---------------------------------------- |
| | 30 | You can add layouts support to your theme by declaring additional layouts in |
| | 31 | your theme's info file. Here is an example: |
| | 32 | |
| | 33 | `example.info` |
| | 34 | |
| | 35 | name = "Example" |
| | 36 | description = "Example theme" |
| | 37 | core = "6.x" |
| | 38 | engine = "phptemplate" |
| | 39 | |
| | 40 | regions[left] = "Left sidebar" |
| | 41 | regions[right] = "Right sidebar" |
| | 42 | regions[content] = "Content" |
| | 43 | regions[footer] = "Footer" |
| | 44 | |
| | 45 | ; Layout: Default |
| | 46 | layouts[default][name] = "Default" |
| | 47 | layouts[default][description] = "Simple two column page." |
| | 48 | layouts[default][template] = "page" |
| | 49 | layouts[default][regions][] = "content" |
| | 50 | layouts[default][regions][] = "right" |
| | 51 | |
| | 52 | ; Layout: Columns |
| | 53 | layouts[columns][name] = "3 columns" |
| | 54 | layouts[columns][description] = "Three column page." |
| | 55 | layouts[columns][stylesheet] = "layout-columns.css" |
| | 56 | layouts[columns][template] = "layout-columns" |
| | 57 | layouts[columns][regions][] = "left" |
| | 58 | layouts[columns][regions][] = "content" |
| | 59 | layouts[columns][regions][] = "right" |
| | 60 | layouts[columns][regions][] = "footer" |
| | 61 | |
| | 62 | Each layout is declared under `layouts` with the key as the identifier that will |
| | 63 | be used by context for this layout. You may use any reasonable machine name for |
| | 64 | each layout, but note that `default` is special -- it will be the default layout |
| | 65 | for your theme if no other layout is specified. |
| | 66 | |
| | 67 | The following keys can be declared for each layout: |
| | 68 | |
| | 69 | - `name`: The human readable name for this layout, shown in the admin UI. |
| | 70 | - `description`: A short description of your layout, same as above. |
| | 71 | - `stylesheet`: A stylesheet to be included with the layout. Optional. |
| | 72 | - `template`: The name of the template file for this layout, without the |
| | 73 | `.tpl.php` extension. |
| | 74 | - `region`: An array of regions supported by this layout. Note that any of the |
| | 75 | regions listed here **must also be declared** in the standard theme `regions` |
| | 76 | array. |
| | 77 | |
| | 78 | |
| | 79 | Example themes |
| | 80 | -------------- |
| | 81 | - Cube, a subtheme included with [Rubik][1] provides a variety of layouts. |
| | 82 | - [Ginkgo][2] the default theme included with Open Atrium. |
| | 83 | |
| | 84 | [1]: http://github.com/developmentseed/rubik/downloads |
| | 85 | [2]: http://github.com/developmentseed/ginkgo/downloads |