2.14. Templates

If you want to tweak the layout of your site this is where you do it. The Template Set Manager (System Module->Templates) allows you to add, delete, edit and duplicate the HTML templates that control block and module layout. Note that you specify the active template set elsewhere (indicated by the checkmark in the right column - System Module->Preferences->General Settings->Default Template Set).

Template manager

Figure 2.14. Template manager

2.14.1. The default template set

XOOPS ships with one template set called “Default”. As a safety precaution you cannot edit or delete this set (if you should mess up your templates you will always have the default set to fall back on). The templates in each set are grouped together by module.

2.14.2. Cloning and downloading template sets

If you would like to create a custom template set you can make a copy of the default set (or any other) by selecting the clone link (you will be prompted to give the new set a name). Unlike the default, other template sets can be freely edited. You can also save a copy of a template set to disk by selecting the download link, or remove it with the delete link. You may also sometimes see an additional Generate link next to new modules for which templates have not yet been created.

2.14.3. Editing templates

You can obtain a full list of a module’s templates by selecting its list link. The list is broken into two parts: The first part lists the ‘page’ templates and the second lists the individual block templates (note that block templates are also accessible via the System Module->Blocks menu->Edit)

The different templates for a single module

Figure 2.15. The different templates for a single module

Here you have the option to delete an individual template, save it to disk (download), upload a new version of a template (using the browse button to select the appropriate file), or to edit it. Selecting the edit link will present you with the actual template code, which you may then modify directly:

Editing a template

Figure 2.16. Editing a template

The preview button will allow you to see the effect of changes in a new window without committing the changes (this is most useful for block templates, previews of page templates may be blank or show arcane fields of variable names). The submit button will save any changes you have made to the template.

While editing templates you must enable a preference that automatically updates module template .html files if there are newer files under the themes/your theme/templates directory for the current theme (System Module->Preferences->General Settings->Update module template .html files from themes/your theme/templates directory? -> “Yes”). This should be turned off once the site goes public.

If you accidentally mess up a template don’t forget that you can retrieve a “good” copy from the default template set. If you are working with non-standard templates it may be a good idea to save a copy to disk before you start modifying them.

2.14.4. Uploading a new template set

You can install new template sets very easily using the form at the bottom of the Template Set Manager. Simply use the browse button to select the appropriate template set package (it must be a tar.gz or .tar file with a valid template set structure). Enter a name for the set (or leave it blank to detect automatically) and hit upload to make it available.