The document object
The document object represents a content document.
-
created
Returns the document created date. -
data
Returns the document data. -
date
Returns the document revision date. -
files
Returns the document associated files. -
hasAccess(permission)
Checks whether the current logged in user has a specified permission over the document. -
id
Returns the document id. -
lock
Returns the document lock object. -
name
Returns the document name. -
online
Returns the document online flag. -
parent
Returns the parent section of the document. -
path
Returns the document path. -
revision
Returns the document revision number. -
user
Returns the document revision author.
data
Returns the document data.
Syntax:
data → document data object
Returns:
The document data.
Example:
The following code finds a document and stores the data object in a variable:
<#assign data = liquidsite.findDocument("Section1/doc1").data>
files
Returns the document associated files.
Syntax:
files → sequence of document file objects
Returns:
The document associated files.
Example:
The following code iterates through the files associated with a document:
<#list liquidsite.findDocument("Section1/doc1").files as file>
Document file: ${file.name} (${file.size} bytes, ${file.mimeType})
</#list>
name
Returns the document name.
Syntax:
name → string
Returns:
The document name.
Example:
The following code obtains the name of a document and assigns it to a variable:
<#assign name = liquidsite.findDocument("Section1/doc1").name>
created
Returns the document created date.
Syntax:
created → date
Returns:
The document created date.
Example:
The following code outputs the document creation date:
<#assign doc = liquidsite.findDocument("Section1/doc1")>
The document was created {doc.created}.
date
Returns the document revision date.
Syntax:
date → date
Returns:
The document revision date.
Example:
The following code outputs the document revision date:
<#assign doc = liquidsite.findDocument("Section1/doc1")>
The document was revided ${doc.date}.
id
Returns the unique document content id.
Syntax:
id → number
Returns:
The document id.
Example:
The following code outputs the document id:
<#assign doc = liquidsite.findDocument("Section1/doc1")>
<p>The document id is ${doc.id}.</p>
lock
Returns the document lock object.
Syntax:
lock → lock
object
Returns:
The document lock object.
Example:
The following code stores the document lock object in a variable:
<#assign lock = liquidsite.findDocument("Section1/doc1").lock>
online
Returns the document online flag.
Syntax:
online → boolean
Returns:
True if the document is online, false otherwise.
Example:
The following code checks the online flag of a document:
<#assign doc = liquidsite.findDocument("Section1/doc1")>
<#if doc.online>
Document has been published and is currently online
</#if>
parent
Returns the parent section of the document.
Syntax:
parent → section object
Returns:
The parent section under which the document is located.
Example:
The following code stores the parent of a document in a variable:
<#assign parent = liquidsite.findDocument("Section1/doc1").parent>
path
Returns the document path.
Syntax:
path → string
Returns:
The document path.
Example:
The following code outputs the path of a document:
<#assign doc = liquidsite.findDocument("Section1/doc1")>
The document path is ${doc.path}
revision
Returns the document revision number.
Syntax:
revision → number
Returns:
The document revision number, or zero (0) if the current revision is an unpublished work revision.
Example:
The following code outputs the revision of a document:
<#assign doc = liquidsite.findDocument("Section1/doc1")>
The document revision is ${doc.revision}
user
Returns the document revision author.
Syntax:
user → user
object
Returns:
The document revision author, or an empty user if the user cannot be found any more.
Example:
The following code assigns the document revision author to a variable:
<#assign user = liquidsite.findDocument("Section1/doc1").user>
hasAccess
Checks if the current user has a specified access permission to the document. The input permission types available are:
- read -- for reading permission (always true)
- write -- for writing permission
- publish -- for publishing permission
- admin -- for administration permission
Syntax:
hasAccess(permission) → boolean
Parameters:
-
permission-- the string containing the permission type (as above)
Returns:
True if the current user has the specified permission, or false otherwise.
Example:
The following code checks if the current user has write access to a document:
<#assign doc = liquidsite.findDocument("Section1/doc1")>
<#if doc.hasAccess("write")>
The current user has write access.
</#if>
