forked from backdrop-ops/slides
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlayouts.html
executable file
·346 lines (313 loc) · 13 KB
/
layouts.html
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Blocks and Layouts in Backdrop CMS</title>
<meta name="description" content="Working with Layouts and Blocks in Backdrop CMS.">
<meta name="author" content="Nate Haug">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:200,300,400,600,700" media="all" />
<link rel="stylesheet" href="reveal.js/css/reveal.css">
<link rel="stylesheet" href="reveal.js/plugin/prism/prism.css">
<link rel="stylesheet" href="reveal.js/plugin/fontawesome/css/font-awesome.min.css">
<link rel="stylesheet" href="reveal.js/css/theme/backdrop.css" id="theme">
<!-- Printing and PDF exports -->
<script>
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match( /print-pdf/gi ) ? 'reveal.js/css/print/pdf.css' : 'reveal.js/css/print/paper.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
<!--[if lt IE 9]>
<script src="reveal.js/lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<section>
<h1 style="font-weight: 400">Blocks and Layouts</h1>
<h3>The <strong>all new</strong> system<br />In Backdrop CMS</h3>
<p><a href="http://backdropcms.org">http://backdropcms.org</a></p>
<img src="assets/layouts/images/Drop_lounging_final_black.png" alt="Drop the dragon lounging" style="width: 50%; padding: 15% 5% 2%;" />
</section>
<section>
<section>
<h1>ALL NEW!*</h1>
<img src="assets/layouts/images/chick-in-hand.jpg" style="width: 80%">
</section>
<section>
<p>*But based on the concepts from Panels<br />and Panels Everywhere in Drupal 7</p>
</section>
</section>
<section>
<section>
<h2>Separating the Concept of Themes and Site Structure</h2>
<div class="column-wrapper">
<div><img src="assets/layouts/images/business_theme.png"></div>
<div><i class="fa fa-arrow-right" style="font-size: 5em; margin-top: .5em;"></i></div>
<div><img src="assets/layouts/images/nexus_theme.png"></div>
</div>
</section>
<section>
<h2>Switching Themes</h2>
<div class="column-wrapper">
<div><img src="assets/layouts/images/business_theme_outlined.png"></div>
<div><i class="fa fa-arrow-right" style="font-size: 5em; margin-top: .5em;"></i></div>
<div><img src="assets/layouts/images/nexus_theme_outlined.png"></div>
</div>
</section>
<section>
<h2>In Drupal 7</h2>
<ul>
<li>Switching themes would move over blocks only if regions had identical names.</li>
<li>Any missing regions? Block positions simply discarded.</li>
<li>Site <strong>structure</strong> (block positions) bound tightly to <strong>appearance</strong> (the theme).</li>
</ul>
</section>
<section>
<h2>In Backdrop</h2>
<ul>
<li>Layouts are separated from themes.</li>
<li>Switching themes has no effect on block positions.</li>
<li>Every theme has a responsive layout.</li>
<li>Site structure decoupled from appearance.</li>
</ul>
</section>
<section>
<h2>New Features and Capabilities</h2>
<img src="assets/layouts/images/layout_selection.png" alt="Layout selection options." />
<ul style="font-size: 80%;">
<li>Multiple layouts! Each URL can have a separate set of regions and blocks.</li>
<li>Reuse blocks as many times as you like in different layouts.</li>
<li>Contexts! Blocks that appear only when certain data (a node, user, etc.) is available.</li>
</ul>
</section>
<section>
<h2>Contexts</h2>
<img src="assets/layouts/images/contexts.png" alt="Detecting contexts." />
<ul style="font-size: 80%">
<li>Blocks that require certain data (e.g. a node) can appear only on certain paths.</li>
<li>Block <em>Conditions</em> can toggle based on available data (e.g. content type)</li>
</ul>
</section>
<section>
<h2>Multiple Contexts</h2>
<img src="assets/layouts/images/context_multiple_path.png" alt="A path with multiple contexts." />
<ul style="font-size: 80%">
<li>Multiple contexts (e.g. both a node and user) can exist at the same path.
<li>If multiple contexts of the same type exist, conditions and blocks automatically provide a select list.</li>
</ul>
</section>
<section>
<h2>User Contexts</h2>
<img src="assets/layouts/images/context_multiple_selection.png" alt="User context selection dropdown." />
<ul style="font-size: 80%">
<li>Current user context is always available.</li>
<li>User paths (e.g. <code>user/%</code>) will provide select list for choosing user context.</li>
</ul>
</section>
</section>
<section>
<section>
<h2>Creating New Layout Templates</h2>
<p>Super easy and familiar for themers</p>
</section>
<section>
<h2>Layout directory structure</h2>
<ul class="file-list">
<li>/layouts/fancypants
<ul>
<li class="file">fancypants.info</li>
<li class="file">fancypants.css</li>
<li class="file">preview.png</li>
<li class="file">layout--fancypants.tpl.php</li>
</ul>
</li>
</ul>
</section>
<section>
<h2>fancypants.info</h2>
<pre><code>
name = Fancy pants
type = layout
backdrop = 1.x
regions[header] = Header
regions[top] = Top
regions[content] = Content
regions[sidebar] = Sidebar
regions[footer] = Footer
</code></pre>
</section>
</section>
<section>
<section>
<h1>Blocks</h1>
<p>Improved and more powerful!</p>
</section>
<section>
<h2>Drupal 7: hook_block_info()</h2>
<pre><code class="language-phpx">
function book_block_info() {
$blocks['navigation'] = array(
'info' => t('Book navigation'),
'description' => t('Shows the table of contents for a book.'),
);
return $blocks;
}
</code></pre>
</section>
<section>
<h2>Backdrop: hook_block_info()</h2>
<pre><code class="language-phpx">
function book_block_info() {
$blocks['navigation'] = array(
'info' => t('Book navigation'),
'description' => t('Shows the table of contents for a book.'),
<span style="color: red;">'required contexts' => array('node' => 'node'),</span>
);
return $blocks;
}
</code></pre>
</section>
<section>
<h2>Drupal 7: hook_block_view()</h2>
<pre><code class="language-phpx">
function book_block_view($delta = '') {
$node = menu_get_object();
$block = array();
if ($node) {
$book_mode = variable_get('book_mode', 'all_pages');
$block['subject'] = t('Table of Contents');
$block['content'] = _book_toc($node, $book_mode);
}
}
return $block;
}
</code></pre>
</section>
<section>
<h2>Backdrop: hook_block_view()</h2>
<pre><code class="language-phpx">
function book_block_view($delta = ''<span style="color: red;">, $settings, $contexts</span>) {
$node = <span style="color: red;">$contexts['node']</span>;
$block = array();
if ($node) {
$book_mode = <span style="color: red;">$settings['book_mode']</span>;
$block['subject'] = t('Table of Contents');
$block['content'] = _book_toc($node, $book_mode);
}
}
return $block;
}
</code></pre>
</section>
<section>
<h2>Hate $delta?</h2>
<ul>
<li>In D7, each module's block hooks had to accomodate <em>all</em> blocks within that module.</li>
<li>Really ugly <code>hook_block_configure()</code>, all forms within a single function.</li>
<li>All hooks need to be in .module file, unnecessary code inclusion.</li>
</ul>
</section>
<section>
<h2>Backdrop: Block Classes</h2>
<pre><code class="language-phpx">
function book_block_info() {
$blocks['navigation'] = array(
'info' => t('Book navigation'),
'description' => t('Shows the table of contents for a book.'),
'required contexts' => array('node' => 'node'),
<span style="color: red;">'class' => 'BookNavigationBlock',</span>
);
return $blocks;
}
</code></pre>
</section>
<section>
<h2>Example Block Class</h2>
<pre style="font-size: 70%"><code>
class BookNavigationBlock extends Block {
function getTitle() {
return = t('Book navigation')
}
function getContent() {
return _book_toc($this->contexts['node'], $this->settings['book_mode']);
}
function form($form, &$form_state) {
return _book_configure_form($form, $form_state);
}
}
</code></pre>
<p>All block callbacks within a single class. No other hooks (hook_block_view(), hook_block_configure(), etc. are necessary.</p>
</section>
</section>
<section>
<h2>Upgrading Sites from Drupal 7</h2>
<ul>
<li>Convert the page.tpl.php from your theme into a stand-alone layout template.</li>
<li>Add a line to your settings.php before upgrading:
<pre><code>
state_set('upgrade_layout_name', <span style="color: red;">'your_layout_name'</span>);
</code></pre>
</li>
<li>Run update.php</li>
<li>Blocks will be moved from theme regions into the layout regions with the same name.</li>
<li>Delete the line in settings.php when done.</li>
</ul>
</section>
<section>
<h2>New Features Coming Soon</h2>
<ul>
<li>Position individual fields in separate blocks (<a href="https://github.com/backdrop/backdrop-issues/issues/1100">Issue #1100</a>)</li>
<li>Add arbitrary nodes to a layout (<a href="https://github.com/backdrop/backdrop-issues/issues/1076">Issue #1076</a>)</li>
<li>Relationships (e.g. Node => Author)</li>
<li>Lots of others! <a href="https://github.com/backdrop/backdrop-issues/issues/345">Meta issue #345</a>
</ul>
</section>
<section>
<h1>Questions?</h1>
<p> </p>
<p>
IRC: #backdrop<br>
<a href="http://backdropcms.org">http://backdropcms.org</a><br>
<a href="http://github.com/backdrop/backdrop">github.com/backdrop/backdrop</a><br>
<a href="http://twitter.com/backdropcms">@backdropcms</a>
</p>
</section>
<section>
<h4>Image Credits</h4>
<p><small>
Chick in hand: http://allnightershop.blogspot.com/2013/09/farmlife.html<br>
</small></p>
</section>
</div>
</div>
<script src="reveal.js/lib/js/head.min.js"></script>
<script src="reveal.js/js/reveal.js"></script>
<script>
// Full list of configuration options available at:
// https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
history: true,
center: true,
transition: 'slide', // none/fade/slide/convex/concave/zoom
// Optional reveal.js plugins
dependencies: [
{ src: 'reveal.js/lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: 'reveal.js/plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'reveal.js/plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'reveal.js/plugin/prism/prism.js', async: true },
{ src: 'reveal.js/plugin/zoom-js/zoom.js', async: true },
{ src: 'reveal.js/plugin/notes/notes.js', async: true }
]
});
</script>
</body>
</html>