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 . 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:
Then test it by entering
http://yoursite.net/tutorial.php3 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
http://yoursite.net/tutorial.php3 (versions of SPIP prior to SPIP 1.9) or
http://yoursite.net/spip.php?page=tutorial, 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:
Finally add any missing fields to refine the display of the article: #SURTITRE, #LESAUTEURS, #SOUSTITRE, #NOTES, etc.