Object viewers

Defining viewer associations

Every object viewer in dmBridge is its own class, in its own file on disk. A number of object viewers are provided (in the dm/objects/helpers/viewers folder) that are capable of handling some common file types. Which viewer is used for which file type depends on the associations defined in the Object View section of the Control Panel.

Due to the way the CONTENTdm® PHP API returns information about files, object viewers in dmBridge are associated with filename extensions. In the Control Panel, you can associate a particular object viewer class with a particular filename extension on a global, per-template-set, or per-collection basis. Be aware that some file formats may have more than one extension (e.g. .tif vs. .tiff), so you'll need to define the association once for each.

Writing custom viewer modules

Every object viewer class must implement the idmViewerDelegate interface. This requires writing just one method - getHTMLTag() - which should return an HTML tag. Take a look at dm/objects/helpers/viewers/dmGenericImageViewer.class.php for an example.

Adding your own custom object viewer is as simple as writing your own class in the pattern of the existing ones and defining the associations in the Control Panel.

You have two choices as to where to save your custom viewer:

  1. If you want it to be available to more than one template set, you can save it in the dm/objects/extensions/viewers folder (not the dmclient/helpers/viewers folder).
  2. If it is template-set-specific, you can also save it in the template set's extensions folder.