Creating a theme for Newscoop 4
A set of page templates can be used to create a Newscoop 4 theme in a single zip file by following four simple formatting rules.
1. A theme.xml file needs to be created before the new theme will show up in the Configure -> Themes page of the Newscoop administration interface. This file contains a name, designer's name, version and description for the theme, and references the default templates and renditions for the theme.
The name= value has to be unique for each new theme that you create, and the require= value specifies the minimum version of Newscoop that the theme was created for. The theme.xml file should also reference some preview screenshots, to help your users identify the theme in the administration interface.
An example theme.xml file could look like this:
My theme
2. The theme files should begin in the root directory of the zip file (not a sub-directory, such as the name of the theme). Sub-directories are allowed for includes such as _tpl and _css, but the four master templates, assigned to the front, section, article and 404 pages, must be in the zip file root.
3. Include paths no longer reference the name of the theme in Newscoop 4.0.0 onwards. All paths are relative to the zip file root. For example, you now include a sub-template like this:
{{ include file="_tpl/_html-head.tpl" }}
instead of the way it was done in Newscoop 3:
{{ include file="set_mytheme/_tpl/_html-head.tpl" }}
So you no longer need to change all the include paths just because you changed the theme name to suit your own project. This will make adapting themes released under GPLv3 much quicker and easier.
4. To avoid hard-coding theme names into link paths, you can use the url static_file function:
instead of using the full link path, which is inflexible if the name of your theme is changed at some point in the future:
Taking a look at the source of the rendered page, the url static_file function should create a link something like this:
Newscoop figures out which publication alias, publication number and theme number you wanted, and constructs the link from that information. This means you can rename themes, fork themes or move them around, and not break links.