My first template

Getting started

How to write your first template that actually works (more or less)

If the template system appears intimidating at first, it is because it offers a range of rich features which demand some complexity. However, complex doesn’t necessarily mean complicated. Here is an example of a basic template.

Materials necessary for this tutorial

-  A SPIP installation. This article assumes that your SPIP database contains at least one section and two published articles. If this is not the case, you can very quickly fix it by copying and pasting any text which you might have available (within sensible limits).

-  A text editor to create and modify the files used by SPIP. Note: some people will automatically want to use Dreamweaver or other graphical (WYSIWYG) software to modify the .html files. However, for simple examples, DreamWeaver will complicate the task and might interfere with the code without you noticing [1]. It really is preferable to use a traditional text editor such as Windows Notepad.

1. For versions of SPIP prior to SPIP 1.9, in order to use a template file, it is necessary to be able to call it. If you are using a later version of SPIP, then jump straight on to the next section. Otherwise, in order to be able to call the template file, create a file called tutorial.php3 in the root of your site containing the following lines:

$fond = "tutorial";
$delais = 0;
include "inc-public.php3";

Then test it by entering in your web browser. Not very successful, is it? The error message informs you that a file is missing. This is the famous template that we will now create.

SPIP 1.9 vastly simplified the template creation process by eliminating this first step for calling a template file. In fact, from version 1.9 onwards, there aren’t any more .php3 (or .php) files for the templates, as they are all calculated from a common unique base script called spip.php. The rest of this tutorial remains valid regardless of the version of SPIP employed.

2. Within the root of the site, create directory called squelettes/ and within that, a file called tutorial.html containing the following code:


When you reload (versions of SPIP prior to SPIP 1.9) or, in place of #TITRE, you should now see the title of your first article (Article No. 1) which SPIP fetched from the database.

If it doesn’t work, check that the status of article no 1 is "published online" and not "submitted for evaluation" or "editing in progress".

Next, add some HTML markup and some other calls to SPIP "fields", and you can quickly display your article:

<div align="justify">#TEXTE</div>

Finally add any missing fields to refine the display of the article: #SURTITRE, #LESAUTEURS, #SOUSTITRE, #NOTES, etc.

Well done!


Author Paul Knight Published : Updated : 26/10/12

Translations : عربي, català, corsu, Deutsch, English, Español, فارسى, français, italiano, 日本語, Nederlands, òc lengadocian, polski, Português, русский, slovenčina, svenska, Türkçe, українська