Skip to main content

The base content object model

Content objects

Tuskfish is designed to allow you to publish common forms of web content - articles, audio, video, images, downloadable files and static pages - and to organise them with subject tags and collections. The different types of content are managed via a single data entry form and co-exist in a common database table.

This works because Tuskfish content objects are designed around the Dublin Core Metadata Element Set, a vocabulary of fifteen properties for describing resources. It doesn't matter whether you are posting an article, photo or video - they all have a title, author, description, publication date, format, type and so on.

Tuskfish uses a subset of the Dublin Core plus a few "web staples" (view counters, submission times etc) to define a base content object, TfContentObject. Each 'type' of content, such as TfishArticle or TfishVideo, is a subclass of this base object, inheriting the common properties and methods of the base content object.

Content subclasses ("content types") simply unset any of the base properties they don't need in their constructor, via a call to zeroedProperties(), and override base methods where they require unique behaviour. You can add additional content types to Tuskfish with only a few minutes work.

Every online content object in the system can be accessed from the home page by passing in its ID as a parameter in the query string, for example: https://yoursite.com?id=42.

Handling content objects

Content objects are retrieved and manipulated using handler classes. The base handler class is TfContentHandler, which should be used when you want to handle multiple content types at once. Some types of content (blocks, collections, tags) also have their own type-specific handler subclass, for example you should use the TfCollectionHandler class when you want to handle TfCollection objects.

The main handler methods you need to know about are:

  • getObject($id): Retrieve a single object based on its ID.
  • getObjects($criteria): Retrieve multiple objects matching $criteria.
  • getListofTitles($criteria): Retrieve an array of object IDs and titles matching $criteria.
  • getCount($criteria): Count the number of objects matching $criteria.

There are more, of course. Please review the method descriptions in the base content handler class to familiarise yourself with the functionality available.

Copyright, all rights reserved.

Related

Tuskfish CMS Developer Guide

This guide will give you an overview of the architecture of Tuskfish CMS, how to write code to perform common operations and how to extend the system to suit yourself. The guide accompanies theĀ Tuskfish API documentation. Keep a copy handy as you read this guide. It is best to review links to the API where provided, as not every detail will be discussed in the text. This is the first version of the guide, so it is still a work in progress.