Note that text shown in this style documents a feature which isn't in the current release but will be in the next release and
text shown thus indicates a feature which is
being removed in the next release.
If you find anything in this documentation which is wrong or unclear then please use the link at the bottom on the page to comment and we will update the page to correct it or make it clearer.
Each page in Opus is essentially displaying an article. There are some special cases, such as the search page, but it is treated as if it's an article. The way the article is displayed is determined by the template which is used to display it. A template is a page of HTML with markers which indicate where the article and other elements are to be inserted to make up a page.
Opus comes with a standard set of templates to start you off. You can modify these templates and add new templates to enhance your web site.
These templates are stored in the directory ./def
. If you want
to change them you should copy them to your paper's directory (typically
./web
) and modify the copy. If you modify the copy in
./def
your changes will be overwritten next time you take a
release of Opus!
In the simple model there are six templates which are used:
default.web.template.html
default.news.template.html
default.xdb.template.html
default.doc.template.html
default.newspage.template.html
default.brief.template.html
The first of these is used for web pages, the second for news pages, the third for datacards (if you have these) and the fourth for articles which are documents e.g. PDF or Word format, and which have a page introducing them. Currently the web, datacard, and document templates are identical.
The last two are used together to create the news page.
default.news.template.html
is the template used for the page
and default.brief.template.html
is used for each of the articles
which are displayed on the page (by default eight articles in two columns of
four).
These templates have much in common so they use a number of include templates. These are:
identify.inc.html |
This is the text that appears in a comment block at the top of each of the templates. It identifies Opus as the system which generated the page and the release number of the software. |
author.inc.html |
This template is empty by default but you can put some text in it about
you and it will be includes in comment block at the top of each of the
templates above the rest of the text in identify.inc.html
|
head.inc.html |
The contents on the [head] section of the page. This is the template which you will typically modify if you want to add some meta tags to your web pages. |
navbar.inc.html |
This defines the layout of the left hand side of each page. |
If you want to use other templates you can define different templates for each section of the site, just store the template in the paper's directory and specify the name of the template in the details of the section.
You can also override the template an article will use based on its section by specifying a template name in the URL. So perhaps you want to display article 10 using a template of newtemplate.html
then the URL will be:
http://yoursite/php/bin/readarticle.php?articlecode=10&template=newtemplate.html
This is useful for two things: testing new templates before you make them live, and for creating specific templates for special pages (this latter use works particularly will if you use URL remapping to manually map the URL of your choice to a URL like the one above).
It is often useful to put comments into your template which you don't want
to be rendered in the HTML which is sent to the reader. You can do this by
wrapping them in "<!--(
" and ")-->
".
You will find examples of this in the default templates supplied with Opus. We chose this method of marking comments as it means that they are also valid HTML comments. Hence if you edit your templates using an editor which understands SGML type markup languages like HTML you should see them highlighted as comments in the same way that other HTML comments are.
Note that we also strip any trailing whitespace from after the
")-->
" as this avoids blank lines appearing in your rendered
page. If for some reason you need whitespace at this point put it before the
comment.
NB: do not put "<" or ">" characters inside HTML comments of any type in a template as the parser will get confused!
The markers which indicate where merge fields are to be inserted are in XML syntax so that there's a sporting chance you will be able to view the template from a web browser. The basic format is:
<opusfield name="fieldname"/>
Where fieldname
is one of the fields listed on this page. Note the trailing "/" at the end of the tag.
Some fields take extra parameters, which may be optional. For example the merge field article
has an optional parameter code
to allow you to include text from another article. So if you wanted to include
the text of article 34 the merge field would look like this:
<opusfield name="article" code="34"/>
Note that unlike HTML all parameters must be delimited by double quotes in XML.
Sometimes you want to put a merge field inside an HTML tag so using XML syntax would mean you would be unlikely to be able to view the template from a web browser so as an alternative you can use braces in place of less than/greater than. So the field above would then be represented as:
{opusfield name="article" code="34"/}
You can see examples of this in the default templates supplied with Opus
in the directory ./php/def
.
You can also have merge other templates into your template using the
merge field "include". This can be done recursively if required
although there may be a performance hit. The main intention behind this
is to allow you to move things which are common for all templates, header
[meta]
tags for example, into a single file for maintenance
purposes and again you can see examples of this in the default templates
which come with Opus.
A fully documented list of all the available merge fields and their parameters can be found here.
The other thing you can do with templates is specify which parts of it are used depending on which browser is being used and whether or not the reader is viewing the "printable" version of the article.
The basic syntax for this is that you surround the bit of the template you only want to be used in some circumstances with:
<opustest name="name" condition="condition">
Bits of template only used if condition is true
</opustest>
The possible values for name
can be found here.
Note that <opustest>
conditions aren't remembered within
templates you've included using the include
merge field discussed
above, so you can't open an <opustest>
in the template and then
close it inside an included template. However you can use
<opustest>
within templates.