Obj

Obj

The base class of CMS objects.

A CMS object is a collection of attributes and their values, as defined by its object class. For custom attributes, various attribute types are available.

System attributes

Obj provides the following system attributes to all CMS objects:

Attribute nameGetterPurposeRead only
_idid()Unique identifier of a CMS object. Can be specified only on object creation. Use id when searching.
_contentIdcontentId()[New in 1.22.0]In a multi-site environment, the key that connects individual pages on two or more sites as language versions of each other. Used by the versionOnSite and versionsOnAllSites instance methods.
_createdAtcreatedAt()Date of the object’s creation.
_firstPublishedAtfirstPublishedAt()Date on which the object was first published.
_languagelanguage()
[New in 1.22.0]Language of the CMS object. The language code must be in accordance with ISO 639-1, e.g. “fr” or “en-US”.
_lastChangedlastChanged()Date of most recent change made to the object.
_objClassobjClass()CMS object model class, e.g. “NewsPage”.
_pathpath()Path in the object hierarchy, e.g. “/about/staff” (optional).

_permalinkpermalink()Unique permanent URL component of the object, e.g. “news” (optional).
_publishedAtpublishedAt()Date of the most recent publish of the object.
_siteIdsiteId()ID of the website the object belongs to. “default” if the Scrivito CMS doesn’t have multi-site enabled.

Static method summary

Instance method summary

  • ancestors()

    Returns the given object’s ancestor Objs, from the root object down to the object’s parent Obj.

  • attributeDefinitions()

    Returns the attribute definitions of the corresponding CMS object class.

  • backlinks()

    Returns a list of all Objs that link to this Obj.

  • children()

    Returns an array of all child Objs of the CMS object.

  • contentLength()

    The content length (byte size) of a binary CMS object.

  • contentType()

    The content type of a binary CMS object.

  • contentUrl()

    The URL of a binary CMS object.

  • copy()

    Creates a copy of the CMS object.

  • createdAt()

    The date the CMS object was created.

  • delete()
    Deletes the CMS object in the current working copy.
  • finishSaving()

    Returns a promise that is resolved after local changes to the CMS object have been saved.

  • firstPublishedAt()

    Returns the date on which the CMS object was first published.

  • get(attributeName)

    Retrieves the value of the specified custom attribute of the Obj.

  • id()

    The unique identifier of the Obj.

  • isBinary()

    Indicates whether the Obj represents binary data.

  • isRestricted()

    Indicates whether or not the Obj is publicly accessible, i.e. visible to anonymous visitors.

  • language()

    Returns the language of the CMS object.

  • lastChanged()

    The date the CMS object was last changed.

  • metadata()

    The metadata of a binary CMS object.

  • modification()

    Returns the modification an Obj has undergone.

  • objClass()

    The object class name of the Obj.

  • orderedChildren()

    Returns an ordered array of all child Objs of the CMS object.

  • parent()

    Returns the Obj representing the path-based parent of the Obj.

  • path()

    The value of the _path attribute of the CMS object.

  • permalink()

    The value of the _permalink attribute of the CMS object.

  • publishedAt()

    Returns the date on which an unmodified CMS object was most recently published.

  • restrict()

    Restricts the visibility of the Obj to logged-in visitors.

  • siteId()

    Returns the site ID of the CMS object.

  • slug()

    The slug of the CMS object.

  • unrestrict()

    Unrestricts the visibility of the Obj, i.e. makes it visible to any visitor (after publishing).

  • update(attributes)

    Updates one or more attributes of the Obj.

  • updateReferences(mapping)

    Updates all references to other CMS objects, based on a mapping function.

  • versionOnSite(siteId)

    Returns an Obj which is a specific language version of the given CMS object.

  • versionsOnAllSites()

    Returns all Objs that are language versions of the given CMS object, for all sites.

  • widget(id)

    Accesses a widget by its id.

  • widgets()

    Returns all the CMS object’s widgets.