| [ Index ] |
PHP Cross Reference of Nucleus CMS 3.32 |
[Summary view] [Print] [Text view]
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 2 <html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <!-- $Id: skins.html 756 2005-08-11 20:28:57Z ehui $ --> 5 <title>Nucleus - Skins and Templates</title> 6 <link rel="stylesheet" type="text/css" href="styles/manual.css" /> 7 </head> 8 <body> 9 10 <div class="heading"> 11 Skins & Templates 12 </div> 13 14 <h1>Introduction</h1> 15 16 <p> 17 <a href="index.html">Back to the manual</a> 18 </p> 19 20 <p>So, you've installed Nucleus... You've got several options now concerning the look of your site:</p> 21 <ol> 22 <li>Go with the default skin/templates that comes with Nucleus</li> 23 <li>Start from the default skin/templates, and modify it to your needs (colors, etc...)</li> 24 <li>Start your own skin/templates, and define your own CSS stylesheets</li> 25 </ol> 26 <p>This document tries to help you with doing this.</p> 27 28 <h1><a id="toc"></a>Table Of Contents</h1> 29 30 <ul> 31 <li><a href="#htmlcss">HTML and CSS</a></li> 32 <li><a href="#defaultskin">The default skin</a></li> 33 <li><a href="#templatesvsskins">Templates vs. Skins</a></li> 34 <li><a href="#skincascade">How skins are chosen</a></li> 35 <li>Howto: 36 <ul> 37 <li><a href="#howto-additem">An 'add item' form on your website</a></li> 38 <li><a href="#howto-cssforms">Using CSS to define the look of forms</a></li> 39 <li><a href="#howto-karma">Enabling karma votes</a></li> 40 <li><a href="#howto-edit">'Edit item'-links</a></li> 41 </ul> 42 </li> 43 <li><a href="#export">Writing skins with Export/Import in mind</a></li> 44 </ul> 45 46 <h1>HTML and CSS <a id="htmlcss" href="#top" class="toplink"><img src="icon-up.gif" width="15" height="15" alt="back to top" /></a></h1> 47 48 <p> 49 When editing skins and templates, you'll need at least some basic knowledge about HTML and CSS. This section provides some pointers to online tutorials and references: 50 </p> 51 52 <ul> 53 <li><a href="http://www.w3schools.com/">W3Schools</a>: online web building tutorials (HTML, XHTML, CSS)</li> 54 <li><a href="http://thenoodleincident.com/tutorials/css/">CSS Panic Guide</a>: links to various CSS resources</li> 55 <li><a href="http://hotwired.lycos.com/webmonkey/authoring/html_basics/index.html">Webmonkey: HTML Basics</a></li> 56 <li><a href="http://hotwired.lycos.com/webmonkey/authoring/stylesheets/">Webmonkey: Stylesheets</a></li> 57 <li><a href="http://diveintoaccessibility.org">Dive Into Accessibility</a>: Online book, not really about HTML, but about accessibility and how to make your site more accessible.</li> 58 </ul> 59 60 61 62 63 64 65 66 <h1>The default skin <a id="defaultskin" href="#top" class="toplink"><img src="icon-up.gif" width="15" height="15" alt="back to top" /></a></h1> 67 68 <p>This section briefly explains which files are used by the default skin, and how you can edit them.</p> 69 70 <p>The default skin uses three files:</p> 71 <ol> 72 <li><tt>default.css</tt>: CSS stylesheet that defines the page style. Colors, layout etc. are defined in this file</li> 73 <li><tt>atom.gif</tt>: The logo that appears in the upper left corner of the screen</li> 74 <li><tt>nucleus2.gif</tt>: Nucleus logo</li> 75 </ol> 76 77 <p>The CSS file <tt>default.css</tt> contains extra information about how pages are built up by the default skins and templates. Basically, it comes down to three <tt>div</tt>-containers: <tt>.contents</tt>, <tt>.logo</tt> and <tt>.menu</tt></p> 78 79 <p>To edit the <tt>default.css</tt> file, you'll need a simple texteditor that does not add extra data, like Notepad (comes with windows),emacs or TextPad. Do <strong>not</strong> use WordPad, Word, OpenOffice Writer, ... since those add extra markup data.</p> 80 81 82 83 84 85 86 <h1>Templates vs. Skins <a id="templatesvsskins" href="#top" class="toplink"><img src="icon-up.gif" width="15" height="15" alt="back to top" /></a></h1> 87 88 <p> 89 In Nucleus, both templates and skins are used to determine the way your blog looks. So, what is the difference between these two? 90 </p> 91 92 <ol> 93 <li> 94 <b>Skins</b> define how your sites look. Each skin consists of several types: one for the main index, one for the detailed item pages, one for the archive, ... 95 The skins also contain instructions of where to include a weblog, and which template should be used to do so. 96 </li> 97 <li> 98 Ha! This means <b>templates</b> are used to define the way the weblog block in your page looks like. The reason why templates aren't included in the skins themselves, is that several skins can use the same template to display a blog. 99 </li> 100 </ol> 101 102 <p>An example is given in the image below. The whole page is defined by a skin, while the parts in the red rectangles (category list and blog contents) are formatted according to the templates. It's the skin that defines where the red rectangles will appear.</p> 103 104 <div class="screenshot"> 105 <img src="pics/skinsandtemplates.png" width="300" height="283" alt="Skins and Templates example" /> 106 </div> 107 108 109 110 111 112 113 114 115 116 <h1>How skins are chosen <a id="skincascade" href="#top" class="toplink"><img src="icon-up.gif" width="15" height="15" alt="back to top" /></a></h1> 117 118 <p> 119 This section tries to explain how Nucleus chooses the skin to use when you request a page. 120 </p> 121 122 <h2>Skin Types</h2> 123 124 <p> 125 First of all, there are several skin types between which Nucleus makes a choice according to the request URL: see the list below. This should be very obvious. 126 </p> 127 128 <table> 129 <tr><th>Query String Format</th><th>Which skin type?</th><th>Which weblog is shown?</th></tr> 130 <tr><td>?itemid=..</td><td>item</td><td>Deducted from <i>itemid</i></td></tr> 131 <tr><td>?archive=..</td><td>archive</td><td>Default weblog, or <i>blogid</i> attribute</td></tr> 132 <tr><td>?archivelist=...</td><td>archivelist</td><td><i>archivelist</i>-attribute</td></tr> 133 <tr><td>?archivelist</td><td>archivelist</td><td>Default weblog</td></tr> 134 <tr><td>?query=...</td><td>search</td><td>Default weblog, or <i>blogid</i> attribute</td></tr> 135 <tr><td>?memberid=..</td><td>member</td><td>None</td></tr> 136 <tr><td>?imagepopup=..</td><td>imagepopup</td><td>None (popup window with image)</td></tr> 137 <tr><td><i>(other or empty)</i></td><td>index</td><td>Default weblog, or <i>blogid</i> attribute</td 138 ></tr> 139 </table> 140 141 <p> 142 Next to these 7 types, there is an <i>error</i> type, which is used when errors occur. 143 </p> 144 145 <h2>The Skin Cascade</h2> 146 147 <p> 148 The table above also indicates how the blog to be displayed is chosen. The skin that will be used, is the default skin for that weblog, as selected in the settings for that weblog. 149 </p> 150 151 <p> 152 Not every skin needs to have definitions for all skin parts. When a part is missing, the skin called 'default' will be used instead (see below). This allows you for example to only create one error page and one member page. 153 </p> 154 155 <h2>The 'default' Skin</h2> 156 157 <p> 158 Nucleus requires that at all times there exists a skin called '<b>default</b>'. This is the skin to which is backed up when a skinpart is missing. If the same skinpart is also missing from the 'default' skin, the error message 'no appropriate skin found' will be shown. 159 </p> 160 161 <p> 162 Another reason why the 'default' skin is required, is to be able to display error messages when no blog is selected (e.g. the 'no such blog' error) 163 </p> 164 165 166 167 168 169 170 171 172 <h1>Howto: An 'add item' form on your website <a id="howto-additem" href="#top" class="toplink"><img src="icon-up.gif" width="15" height="15" alt="back to top" /></a></h1> 173 174 <p> 175 Nucleus provides facilities to add an 'add item' form to your weblog. It adds an 'add item' link that shows and hides the 'add item' form right above the current contents of your weblog. Entering text in this form results into an instant preview, so you can immediately see how the actual weblog item will look like. 176 </p> 177 178 <p> 179 All modifications below apply to the <b>skin</b> for the <b>main index</b> page. You don't need to alter any templates. 180 </p> 181 182 <h2>1. JavaScript code</h2> 183 <p> 184 First of all, you need to include the edit.js Javascript code by putting the following line somewhere in between the <head> and </head> tags. This file contains the functions that are needed to make the preview work and to hide/show the 'add item' form. 185 </p> 186 187 <pre> 188 <script type="text/javascript" 189 src="nucleus/javascript/edit.js"></script> 190 </pre> 191 192 <h2>2. Indicate where the form will show up</h2> 193 194 <p> 195 The, you add a logical container somewhere on your page, where you want to have the 'add item' form. The "display:none;" makes sure it is hidden. 196 </p> 197 198 <pre> 199 <div id="edit" style="display:none;"> 200 ... 201 </div> 202 </pre> 203 204 <h2>3. Code that inserts the form and preview</h2> 205 206 <p> 207 Now, you can add your custom HTML into this container, and use <%additemform%> and <%preview(<i>templatename</i>)%> to insert the 'add item' form and the preview code respectively. An example is given below 208 </p> 209 210 <pre> 211 <h2>Add Item</h2> 212 <%additemform%> 213 214 <h2>Preview</h2> 215 <%preview(mytemplate)%> 216 </pre> 217 218 <h2>4. The 'add item'-link</h2> 219 <p> 220 And the finishing touch: a link or button to trigger the visibility of the form. Two examples are given. The first one is a simple link: 221 </p> 222 223 <pre> 224 <a href="javascript:showedit();">add item</a> 225 </pre> 226 227 <p> 228 The second example is a hidden button in the topleft corner 229 </p> 230 231 <pre> 232 <div style="position: absolute; left: 0px; 233 top: 0px; width: 10px; height: 10px" 234 onclick="javascript:showedit();"> 235 </div> 236 </pre> 237 238 239 240 241 242 243 <h1>Howto: CSS to define the look of forms <a id="howto-cssforms" href="#top" class="toplink"><img src="icon-up.gif" width="15" height="15" alt="back to top" /></a></h1> 244 245 <p> 246 Through variables such as <%searchform%> and <%commentform%>, forms can easily be included into your skin. To allow styles to be applied on those forms, CSS classes have been assigned to the input fields and buttons, and to a surrounding DIV-container. 247 </p> 248 249 <p> 250 Below is a list of which CSS class corresponds to which form. These are the classes assigned to the surrounding DIV-container. 251 </p> 252 253 <table> 254 <tr> 255 <th>Form Type</th> 256 <th>Skin Variable</th> 257 <th>CSS Class Name</th> 258 </tr> 259 <tr> 260 <td>Add Item to Blog</td> 261 <td><%additemform%></td> 262 <td>.blogform</td> 263 </tr> 264 <tr> 265 <td>Add Comment</td> 266 <td><%commentform%></td> 267 <td>.commentform</td> 268 </tr> 269 <tr> 270 <td>Login Form</td> 271 <td><%loginform%></td> 272 <td>.loginform</td> 273 </tr> 274 <tr> 275 <td>Search Form</td> 276 <td><%searchform%></td> 277 <td>.searchform</td> 278 </tr> 279 <tr> 280 <td>Member to Member Mail</td> 281 <td><%membermailform%></td> 282 <td>.mailform</td> 283 </tr> 284 </table> 285 286 <p> 287 Below is an overview of the CSS classes assigned to buttons and input fields. 288 </p> 289 290 <table> 291 <tr> 292 <th>Type</th> 293 <th>CSS Class Name</th> 294 </tr> 295 <tr> 296 <td>Input fields (text and textarea)</td> 297 <td>.formfield</td> 298 </tr> 299 <tr> 300 <td>Buttons</td> 301 <td>.formbutton</td> 302 </tr> 303 </table> 304 305 <p> 306 An example of how to use these classes in you stylesheets is given below: 307 </p> 308 309 <pre> 310 /* applies to all input fields */ 311 .formfield { 312 background-color: gray; 313 } 314 315 /* only applies to buttons for comment forms */ 316 .commentform .formbutton { 317 border: 1px solid #000; 318 background-color: #ddd; 319 color: #000; 320 font-size: xx-large; 321 } 322 </pre> 323 324 <p>In the example above, all formfields that nucleus generates are given a gray background, and the submit button on the comment form has large text, a black 1px border, black text and a light-gray background.</p> 325 326 327 <h1>Howto: Enabling karma votes <a id="howto-karma" href="#top" class="toplink"><img src="icon-up.gif" width="15" height="15" alt="back to top" /></a></h1> 328 329 <p>The default skins and templates have karma votes disabled (better: left out). Here's how to add them to your <i>template</i>.</p> 330 331 <h2>1. Open the template for the main index</h2> 332 333 <p>Start editing the template named <tt>'default'</tt> (when starting from the default skins/templates that come with Nucleus)</p> 334 335 <h2>2. Edit the 'Item body' template-part</h2> 336 337 <p>Edit the <i>bottom part</i> of the item body templatepart to be as follows:</p> 338 339 <pre> 340 <div class="iteminfo"> 341 <%time%> - 342 <a href="<%authorlink%>"><%author%></a> - 343 karma: <%karma%> 344 [<a href="<%karmaposlink%>">+</a>/<a href="<%karmaneglink%>">-</a>] - 345 <%edit%> 346 <%comments%> 347 </div> 348 </pre> 349 350 <p>On the main page, the iteminfo line for the items will now look like:</p> 351 352 <div><i>9:00:39 PM - <a href="">God</a> - karma: 5 [<a href="">+</a>/<a href="">-</a>] - <a href="">edit</a></i></div> 353 354 <h2>3. Template for the detailed pages</h2> 355 356 <p>At this time, the karma score is only listed on the main page. To make it appear on the detailed page also, the same change needs to be applied to the template with name '<tt>detailed</tt>'</p> 357 358 359 360 361 362 363 <h1>Howto: 'edit item' links <a id="howto-edit" href="#top" class="toplink"><img src="icon-up.gif" width="15" height="15" alt="back to top" /></a></h1> 364 365 <p>The default Nucleus skin includes 'edit item'-links that are only visible to the author of a item and to the people having the right to alter the item. This section explains which template-parts are needed for this feature to work.</p> 366 367 <h2>'editlink'-template</h2> 368 369 <p>The 'Edit Link'-templatepart defines how an 'edit item'-link is formatted. By default, the contents is:</p> 370 <pre><code><a href="<%editlink%>" onclick="<%editpopupcode%>">edit</a></code></pre> 371 372 <p>If you would rather edit the item in the admin area, instead of in the popup bookmarklet, use the following code instead:</p> 373 374 <pre><code><a href="nucleus/index.php?action=itemedit&amp;itemid=<%itemid%>">edit</a> 375 </code></pre> 376 377 <h2>Positioning the edit-link</h2> 378 379 <p>Next to the 'editlink' template, there's the <code><%edit%></code>-templatevar that, when placed somewhere in the 'item body'-templatepart, inserts the editlink.</p> 380 381 <p>See the example from the <a href="#howto-karma">karma votes howto</a> to see an example.</p> 382 383 384 385 386 <h1>Writing skins with Export/Import in mind <a id="export" href="#top" class="toplink"><img src="icon-up.gif" width="15" height="15" alt="back to top" /></a></h1> 387 388 <p>Nucleus v2.0 introduced the ability to import and export skins and templates. This section describes the creation of a simple skin, highlighting the features involved.</p> 389 390 <h2>Creating a new skin</h2> 391 392 <ol> 393 <li> 394 <p>First, we're going to create a new skin from the admin area. Browse to <code>Nucleus Management > Edit Skins</code> and scroll to the bottom of the page. Let's call this skin '<strong>vista</strong>'</p> 395 </li> 396 <li> 397 <p>Now look up the 'vista' skin in the skin list and go to the <code>Edit</code> screen. The content type is set to <code>text/html</code>. That's what we want, so no need to change that</p> 398 <p>The <code>Include Mode</code> and <code>Include Prefix</code> setting reuire more attention. To export a skin, we like to have all files (images, stylesheets, etc...) under one single directory. Remember the <code>$DIR_SKINS</code> setting in <code>config.php</code> and the <code>Skins URL</code> in the general site settings? Suppose these were as follows:</p> 399 <pre><code>/home/user/example/htdocs/skins/ 400 http://example.org/skins/</code></pre> 401 <p>Then we would like to put our files in</p> 402 <pre><code>/home/user/example/htdocs/skins/vista/ 403 http://example.org/skins/vista/</code></pre> 404 <p>And this is what the <strong><code>Include Mode</code></strong> is for. Setting it to <strong>Use skin dir</strong> will do this.</p> 405 <p>The <strong><code>Include Prefix</code></strong> also plays a role. This is the <strong>vista/</strong> part</p> 406 <p>An overview of the correct settings:</p> 407 <ul> 408 <li><strong>Name</strong>: vista</li> 409 <li><strong>Content Type</strong>: text/html</li> 410 <li><strong>Include Mode</strong>: Use skin dir</li> 411 <li><strong>Include Prefix</strong>: vista/</li> 412 </ul> 413 </li> 414 </ol> 415 416 <h2>Edit the skin</h2> 417 418 <p>The <code>IncludeMode</code> and <code>IncludePrefix</code> settings will cause the <code>include</code>, <code>phpinclude</code> and <code>parsedinclude</code> skinvars to get their files from the skindir. Next to that, there's the <code>skinfile</code> skinvar, which translates its argument to an URL relative to the skinsdir.</p> 419 420 <p>In our case:</p> 421 422 <pre><code><%skinfile(myFile.jpg)%></code></pre> 423 424 <p>Will get expanded to:</p> 425 426 <pre><code>http://example.org/skins/vista/myFile.jpg</code></pre> 427 428 <p>Lets go easy on ourselves and define the global layout in two files called <code>pagefoot.inc</code> and <code>pagehead.inc</code>, which we place in our <code>vista/</code> directory:</p> 429 430 <h3>pagehead.inc</h3> 431 432 <pre><code><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 433 <html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"> 434 <head> 435 <title>My Site</title> 436 <link rel="stylesheet" type="text/css" href="<%skinfile(layout.css)%>" /> 437 </head> 438 <body> 439 440 <div id="contents"></code></pre> 441 442 <h3>pagefoot.inc</h3> 443 444 <pre><code></div><!-- contents div end --> 445 446 <div id="stuffbar"> 447 <h2>Navigation</h2> 448 449 <ul> 450 <li><a href="<%todaylink%>">Today</a></li> 451 <li><a href="<%archivelink%>">Archives</a></li> 452 </ul> 453 454 <h2>About</h2> 455 456 <ul> 457 <li><a href="http://www.nucleuscms.org/">Nucleus</a> Power!</li> 458 </ul> 459 </div><!-- stuffbar end --> 460 461 </body> 462 </html></code></pre> 463 464 <p>The contents of the skinparts then becomes kind of trivial: (I'm not defining them all, you'll get the point by seeing the most important ones)</p> 465 466 <h3>Main Index</h3> 467 <pre><code><%parsedinclude(pagehead.inc)%> 468 469 <h1>My Blog</h1> 470 471 <%blog(vista/main,10)%> 472 473 <%parsedinclude(pagefoot.inc)%></code></pre> 474 475 <h3>Item Pages</h3> 476 477 <pre><code><%parsedinclude(pagehead.inc)%> 478 479 <h1>My Blog</h1> 480 481 <h2>Item</h2> 482 <%item(vista/detailed)%> 483 484 <h2>Comments</h2> 485 <%comments(vista/detailed)%> 486 487 <h2>Add Comment</h2> 488 <%commentform%> 489 490 <%parsedinclude(pagefoot.inc)%></code></pre> 491 492 <p>Note that I named my templates <strong>vista/main</strong> and <strong>vista/detailed</strong>. Makes it easier to see things together six months later. Both templates are actually clones that I made of the <strong>default</strong> and <strong>detailed</strong> templates that come with Nucleus.</p> 493 494 <h3>Archive List</h3> 495 496 <pre><code><%parsedinclude(pagehead.inc)%> 497 498 <h1>My Blog</h1> 499 500 <%archivelist(vista/main)%> 501 502 <%parsedinclude(pagefoot.inc)%></code></pre> 503 504 <h3>Archive</h3> 505 506 <pre><code><%parsedinclude(pagehead.inc)%> 507 508 <h1>My Blog</h1> 509 510 <%archive(vista/main)%> 511 512 <%parsedinclude(pagefoot.inc)%></code></pre> 513 514 <h2>Export the skin</h2> 515 516 <p>When all is done, you can export the skin from the <code>Skin Import/Export</code> page in the admin area. Here's what to do:</p> 517 518 <ol> 519 <li>Select vista, vista/detailed and vista/main from the skins and template list</li> 520 <li>Add some textual description and hit the <code>Export selected skins/templates</code> button. It will generate a <code>skinbackup.xml</code> for you.</li> 521 <li>Save this <code>skinbackup.xml</code> file together with the other files in the <code>vista/</code> directory.</li> 522 <li>Package all files from the vista directory inside a zipfile</li> 523 <li>All done! Your skin can now be shared with others</li> 524 </ol> 525 526 <h2>Importing a skin</h2> 527 528 <p>Importing is the reverse process:</p> 529 530 <ol> 531 <li>Unzip the zip file under your skins directory, so you end up with a <code>vista/</code> dir (there will be one directory per skin)</li> 532 <li>From the <code>Skin Import/Export</code> page in the admin area, select <code>vista</code> from the dropdown, and click the <code>Import</code> button.</li> 533 <li>Follow the instructions</li> 534 <li>The skin is now installed. It can be selected from the blogsettings.</li> 535 </ol> 536 537 </body> 538 </html>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Tue Feb 12 15:34:36 2008 | Cross-referenced by PHPXref 0.7 |