Jump to content

User:Robbiemuffin/Templates/Contents Block/doc

From Wikibooks, open books for an open world
 

{{User:Robbiemuffin/Templates/Content Block}} — Content Block

Purpose

[edit | edit source]

To separate substance from style in Book Contents. The intended use is (for example) for the book to handle loosely organized (or even unorganized) pages with category tags, where the category is transcluded through a list formatter into the contents, TOC, and index.

Technical Details

[edit | edit source]

Specification

[edit | edit source]
<div style="
  float: {{#if:{{{float|}}}|{{{float|}}}|right}}; 
  position: relative; 
  background-color:{{#if:{{{bgc|}}}|{{{bgc|}}}|#eef}}; 
  padding: 1em 1.25em 3em 1.25em; 
  border-radius: 2em; -webkit-border-radius: 2em; -moz-border-radius: 2em;">

    <div style="
      width: 100%; 
      margin-left: auto; margin-right: auto; 
      text-align: center; 
      font-variant: small-caps; 
      letter-spacing: 0.3em">
        {{#if:{{{title|}}}|{{{title|}}}|Contents}}
    </div>

<div style="line-height: 1em"> </div>

    <div style="
      padding: 1em; 
      background-color: rgba(255,255,255,0.35); 
      {{#if:{{{maxwidth|}}}|max-width: {{{maxwidth|}}};|}} 
      {{#switch:{{{withback|}}}
        |f=
        |border-radius: 0.5em; -webkit-border-radius: 0.5em; -moz-border-radius: 0.5em;
      }}">
          {{#if:{{{contents|}}}
            |{{{{{contents|}}}}}
            | <span style="font-family: monospace">
                Your contents would go here
              </span>
           }}
    </div>
</div>
{{#if:{{{clear|}}}|<div style="clear:both; font-size: 1px; line-height: 1px;"> </div>|}}

Usage

[edit | edit source]

{{User:Robbiemuffin/Templates/Contents Block | title=my_title | contents=my_cat' | maxwidth=max_width' | float=left_or_right' | bgc=rgb_color' | withback=t_or_f'}}

title Title text for the Contents block. Defaults to "Contents"
contents Required value. The category page where you are writing out your contents, as displayed in the title text on that page.
maxwidth If set, passes a max-width CSS tag with the value set here to the div for the actual content.
float Float left or float right for content block. Defaults to right.
bgc Background color for content block. Defaults to #eef.
withback Lighter background for the actual content. Defaults to true. (Set to "f" to override.)
clear Postpend contents with a clear:both div.


 

Example

[edit | edit source]

Prep

First, you need to make a page that lists your contents. In this example we use: User:Robbiemuffin/Templates/Contents Block/doc/SampleContents, but normally you would have some form of transclusion and category automatically generate the list.

Code

{{User:Robbiemuffin/Templates/Contents Block
|title='''''What's Inside'''''
|contents=User:Robbiemuffin/Templates/Contents Block/doc/SampleContents
|clear=yes please
}}

note that the content tag is actually space- and case-sensitive!

Output

What's Inside
 
Chapter 1 Overview of China
Chapter 2 Etymology
Chapter 3 History
Chapter 4 Timeline
 


See also

[edit | edit source]
 
this page was brought to you by an Ajax hacker