public
Description: An extension for Radiant CMS which provides tags for creating nested layouts.
Homepage: http://webadvocate.com/radiant-nested-layouts-extension
Clone URL: git://github.com/moklett/radiant-nested-layouts-extension.git
100644 126 lines (93 sloc) 3.378 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
= Nested Layouts
 
An extension for Radiant CMS which provides tags for creating nested layouts.
 
Nested Layouts enables reuse of a top-level "master" layout (one that contains your <html> tags and the overall
structure/wrapper of your site) for several different "nested" layouts (i.e. a one-column layout and a
two-column layout). Keep your layouts DRY!
 
 
== Installation
 
Place the files for this extension within vendor/extensions/nested_layouts in your Radiant application, and
restart your server.
 
Via git clone:
git clone git://github.com/moklett/radiant-nested-layouts-extension.git vendor/extensions/nested_layouts
 
Via piston (requires piston with git support, and your working copy to be in svn or git):
piston import git://github.com/moklett/radiant-nested-layouts-extension.git vendor/extensions/nested_layouts
 
Via download:
http://github.com/moklett/radiant-nested-layouts-extension/tarball/master
 
=== Requirements
 
Radiant CMS 0.6.5 or newer. (Although I believe 0.6.4 and earlier will work, if you change occurrences of
'page.layout' to 'page._layout' in the extension)
 
http://radiantcms.org/
 
 
== Usage
 
Two new tags are provided for use in your layouts:
 
- <r:content_for_layout/>
  This tag is replaced by either (1) the contents of an <r:inside_layout> tag which specifies this layout
  in its +name+ attribute, or (2) the 'body' part of the page you are rendering (behaving just like a
  vanilla <r:content/> tag)
 
- <r:inside_layout name="[your layout name]">
  The contents of an inside_layout tag are placed within the named layout, at an instance of a
  content_for_layout tag.
  
=== Example
 
Given the following Homepage and Layouts...
 
Homepage:
  <p>Hello World!</p>
  
Layouts:
  master:
    <html>
      <body>
        <r:content_for_layout/>
      </body>
    </html>
    
  one-column:
    <r:inside_layout name="master">
      <div id="main-column">
        <r:content_for_layout/>
      </div>
    </r:inside_layout>
    
  two-column:
    <r:inside_layout name="master">
      <div id="left-column">
        <r:content_for_layout/>
      </div>
      <div id="right-column">
        Sidebar!
      </div>
    </r:inside_layout>
 
You can set the Layout for your Page (within the Radiant admin) to any one of 'master', 'one-column', or
'two-column'. The real power of nested_layouts comes from setting your Page layouts to a nested layout
(either 'one-column' or 'two-column' in this example). Then, any changes you make to the top-level 'master'
layout will be reflected in all of your pages!
 
Setting the Layout for "Homepage" to "one-column" renders:
 
  <html>
    <body>
      <div id="main-column">
        <p>Hello World!</p>
      </div>
    </body>
  </html>
  
Setting the Layout for "Homepage" to "two-column" renders:
 
<html>
  <body>
    <div id="left-column">
      <p>Hello World!</p>
    </div>
    <div id="right-column">
      Sidebar!
    </div>
  </body>
</html>
 
 
You can also nest layout multiple times. Given the above Layouts, and creating a new one:
 
Layout "nest-me":
  <r:inside_layout name="one-column">
    <div id="nest-me">
      <r:content_for_layout/>
    </div>
  </r:inside_layout>
  
Setting your "Homepage" layout to "nest-me" would render:
 
  <html>
    <body>
      <div id="main-column">
        <div id="nest-me"
          <p>Hello World!</p>
        </div>
      </div>
    </body>
  </html>