|
Opus 2.30 Publisher's Manual Product Overview Installation and Set Up Customising a Paper Templates Using Datacards Using Objects Author Maintenance Activity Logging Technical Issues Appendices |
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.
An object in Opus consists of three elements: its name, which can be up to twenty characters, its description, which describes what it is, and its content, which can be up to 64Kbytes of text. This text can include HTML but not Opus mark up.
You can insert the content of an object into a web page in two ways:
{object:name}
<opusfield name="object" object="name"/>
There are three sorts of objects: system, user and paper.
System objects have names beginning with a "$" and let you insert changing system information from Opus in your web pages. The following system objects are available:
| $time-12hm | Time now in 12 hour HH:MM format | 10:11 am |
| $time-12hms | Time now in 12 hour HH:MM:SS format | 10:11:55 am |
| $time-24hm | Time now in 24 hour HH:MM format | 10:11 |
| $time-24hms | Time now in 24 hour HH:MM:SS format | 10:11:55 |
| $date-iso | Today's date in ISO format (YYYY-MM-DD) | 2026-04-09 |
| $date-dmy | Today's date in DD/MM/YY format | 09/04/26 |
| $date-mdy | Today's date in MM/DD/YY format | 04/09/26 |
| $date-long | Today's date in long format | 9th April, 2026 |
| $date-arpa | Date/time in RFC922 (APRA) format | Thu, 09 Apr 2026 10:11:55 +0100 |
| $day-short | Day in three letter short format | Thu |
| $day-long | Day in long format | Thursday |
| $month | Month name | April |
| $year | Year | 2026 |
| $copy-years | Range of years from a year until now e.g. {object:$copy-years>2011} | 2026 |
| $author-name | The author's name if the someone is logged on | John Smith |
| $opus-release | Current Opus release | 3.00 |
| $opus-release-full | Current Opus release including sub-release number | 3.00.6 |
| $meta_og | 'meta property="og:...' tags (needs significant set up) | - |
| $mp3 | An MP3 player, syntax {object:$mp3>URL of MP3} | an MP3 player |
| $moved | Page permanently moved syntax {object:$moved>new URL} | Hops reader to new URL - note warning when editing |
| The size of an external PDF, syntax {object:$pdf>250} | (Adobe/PDF, 250KB) | |
| $tweet | Twitter tweet {object:$tweet>unique_id} | a Twitter tweet |
| $youtube | An embedded YouTube video {object:$youtube>unique_id} | a YouTube video |
| [Unknown user object ] |
You can update objects from within Opus using the "Browse objects" option in the author menu.
Assuming that you have access to the MySQL server and the right permissions you can update an object from outside Opus using the shell script ./bin/opus_object.sh. This script is a pipe which takes five parameters. You send the content you want to insert to:
| opus_object host user pass database name [desc [paper]]where host is the host where the MySQL server lives, user and pass are the username and password for accessing the database, database is the Opus MySQL database you want to update, and name is the name of the object you want to update. You can optionally pass a description in desc and, if you've got more than one paper, you need to identify that by passing the papercode in paper (assumed to be 1 if not passed).
Is is possible to embed PHP code within an object. This is a powerful and
potentially dangerous feature in the wrong hands so only the publisher can
create such objects. An object which uses PHP must begin <?php
and end ?>. When the code is run it must set a variable
$contents which contains the contents of the object which are
to be displayed.
Your web browser isn't the ideal PHP programming editor so it's perfectly
possible to include code from a file. We have an object camweather
which we use in the
Milton Village
site which displays the current weather in a text box. The PHP code for this is
in a file weather.inc and the object contents are simply:
<?php
include("../web/weather.inc");
?>
If you want to go beyond the embedding of PHP into a user object you can use a paper object. You would use this if you need to do something complicated in PHP. You create a file objects.inc in your paper's directory.
This should include within it a function paper_object() which takes a single parameter, the name of an object, and returns the value of the object.
Your code can do what it likes, although for safety you should precede any functions you create with a suitable prefix so you don't get function name clashes with Opus - a good choice would be local_.
Having created the object in your function paper_object() you must also define in it Opus. You can do this using the "Browse objects" option in the author menu.
You can now use the object in your templates or articles, prefixed by "#". Here's a simple example of an objects.inc file:
<?php
function paper_object($name)
{
switch { $name }
{
case "test":
return "Hello world";
default:
return "[Unknown object ".$name."]";
}
}
?>
You can then refer to this in an article as {object:#test} and will result in the text "Hello world" appearing in the article at the position when it's published.
Note the error message returned if the object name isn't recognised: if you use this exact format then when checking an article an author has written Opus can spot invalid objects.
System objects are useful for inserting information into web pages which changes often, like today's date and the usefulness of paper objects is only limited by your imagination.
User objects are useful for two things: as a shorthand for putting long bits of text into an article which occurs on many pages (but do think about doing this from the template, possibly using an <opustest> ... </opustest> portion of the template).
They are also useful for other information which changes often. For example suppose you change the sales executive responsible for modem sales fairly often but you need to refer to that sales executive by name in every web page (i.e. article) about a modem.. Then you can create an object named modem-salesexec and in all your articles about modems you would put:
Contact {object:modem-salesexec} for more information.And then by changing the contents of the modem-salesexec object all the pages referring to it would change automatically.