Include Tutorial

The content on this page is incomplete and currently in development.

This tutorial will focus on the include pages found for the iNews website. The include pages are the global templates that form a consistent nature for the site. They allow you to input certain pieces of information, and the page formatting automatically sets. So, not only do the include pages make it easy for you to add formatting, it also helps the site look consistent and professional throughout.

In order for an include to be defined, you must type [[include inc:pagename]]. The page name is the name of the page being summoned for inclusion. Before talking about the different includes this site uses, I will explain the mechanics of the include pages as well as how to use them so that you might be more comfortable with them.

Include Pages

For an include page to work, it must first have a parent page, so to speak. This page can be found in the inc: category for this site. Pages in the inc: category usually look like some page with formatting that have strange coding or symbols on it. For example, you might look at a page called inc:sidebar, and it might look like this:


{$sidebar}


{$maincontent}

This page serves as the template for other pages. Therefore, when you include the page, you will get that.

Include Variables

The include variables are the words and content encased in {$text}. When including pages, these are the things that you can replace. In the example above, there are two variables: the {$maincontent} and {$sidebar}. Whenever you define the variable {$maincontent}, whatever you define it as will replace the variable.

Defining Variables

The main purpose of the includes is to define the variables they contain. That way, you can add content easily. To define a variable, add a vertical divider (|) followed by the variable name. Then, put an equals, and begin defining the variable. So, an include defined as [[include inc:sidebar |maincontent=This is the main content of the page. I am on the left side of the side bar. |sidebar=This is the side bar content. Anything written after this variable will be put in the side bar area.]], will render:


This is the side bar content. Anything written after this variable will be put in the side bar area.


This is the main content of the page. I am on the left side of the side bar.

To make it easier to read, you can write it like this and still get the same effect.

 [[include inc:sidebar
|maincontent=This is the main content of the page.  I am on the left side of the side bar.
|sidebar=This is the side bar content.  Anything written after this variable will be put in the side bar area.
]]

As a warning, sometimes when you do not put anything after the equals, the variable name shows.

Special Includes

The includes used on this site are a little special since you can leave a variable undefined and it will simply replace the variable with a default definition. This is done with a crazy little syntax I like to call Boolean logic.

Simply, these includes require a backend include and primary include (both of which are individual pages). The backend page has all the formatting and a copy of each variable hidden in invisible comments. Using the same side bar example, it would look like this:

[[div style="float:right; width: 20em; padding: 0 1em 0 1em; margin: 0 0 1em 1em; border: 1px solid #242424; background: #EEEEEE;"]]
[!-- {$sidebar} --][[[@@|]]] {$sidebar}
[[/div]]
[!-- {$maincontent} --][[[@@|]]] {$maincontent}
~~~~

The weird @ thing is what defines an If…Then condition.

The primary include page includes the backend and defines what the variables are in case they aren't defined. It would look like this:

 [[include inc:sidebar-backend
|sidebar={$sidebar} |sidebar=No side bar content.
|maincontent={$maincontent} |maincontent=@@
]]

So, let's say someone put this on the page.

 [[include inc:sidebar
|sidebar=
|maincontent=This is the main content of the page.
]]

It would render:

No side bar content.


This is the main content of the page.

So, what happens when the maincontent is left blank? Will it put a @@?

Actually, it will not. @@ is a special syntax that tells the page to put nothing. If the @'s weren't there, the {$maincontent} would appear.

Most of the includes in this website are like this, so most of the time, you shouldn't have to worry about defining variables.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License