GLOSSARY
PICTOGRAMS DEFINITION
 
GET EXTRA INFO

 
CLICK AND PLAY

Work with templates
Understand the use and edit templates
All the versions of this article: فارسى | English
Lessons you should have completed:
General overview
Install SPIP Offline

What will I learn to do?

You have probably noticed that SPIP sites look and feel can differ quite a lot from one another. Images, colours, navigation, home page, articles, forums organisation etc... can all vary from one site to another.

This site-specific customisation is made possible thanks to special files called templates.

In this lesson you will learn:

- What a SPIP template is all about and what uses you can make of it

- Where the templates of your SPIP site can be found on the server

- How to create a simple template

- How to integrate an existing set of templates

Audience Pre-requisites

Before starting this lesson:

- You should have basic HTML skills

- You should read the "Install SPIP offline" article in order to have a SPIP test site installed on the your computer.

What’s a SPIP template all about and how can I use it?

Templates are HTML files that extract the information stored in the database and format it to create the pages of your Public site.

If you modify the templates of your site, you will present the content of your site in a different way without changing the content itself.

 

For example when using one particular article template, the date and the name of the author is displayed at the beginning of the article.

 

With another template the date and the name of the author is displayed just after the title and the subtitle.

BEST PRACTICE

As a webmaster, do I have to master templates?

As a webmaster, you have a vested interest in mastering templates.

Even if the standard templates or the templates you might get through contribution are generally OK, they will never fulfill 100% of your specific requirements.

For instance on the site http://india.eu.org/ a keyword navigational menu was added on the top of the page while the rest of the ditrib template remained unchanged.

The loops : the key elements in templates

Loops represent the starting instruction used in all the templates.

They are written in a special SPIP syntax, and are embedded in the HTML code of the templates.

AUDIENCE VIEW

For instance in a template for sections, the list of all the articles belonging to that section will be displayed by creating a loop on articles.

The instruction will consist in saying "loop all the articles present in this section" and inside the loop, the title of the article will be displayed as a clickable link.

Where can the templates be found on the server?

At the root of a SPIP site there are two important folders:

- ’dist/’ which contains the default templates

- ’ecrire/’ which contains the SPIP core code

 

To create a new set of templates, simply create a folder called ’squelettes/’ at the root of your SPIP site.

It is not mandatory to place a complete set of templates there.

 

Now if you call article 10 by typing:

http://mywebsite.com/spip.php?article10,

The folder ’squelettes/’ will first be checked and if a template called ’article.html’ can be found in it, this template will be used to display the article.

If the folder ’squelettes/’ or if ’article.html’ within this folder cannot be found, then the system will default to the ’article.html’ located in ’dist/’.

CAUTION

Do not modify the templates located in the ’dist/ folder as they will be a useful reference point. Also, by keeping your own templates in a separate folder you will not overwrite them when you next upgrade SPIP.