The topic object

The topic object represents a forum topic.


findPost

Returns a specified post in the topic.

Syntax:

findPost(id) → post object

Parameters:

Returns:

A specified post in the topic.

Example:

This code gets a topic post from its id and assigns it to a variable:

<#assign post = topic1.findPost(id)>

findPosts

Returns a number of posts in the topic.

Syntax:

findPosts(offset, count) → sequence of post objects

Parameters:

Returns:

A list of at most count posts in the topic, beginning at post number offset.

Example:

This code loops through the first ten posts in a topic:

<#list liquidsite.findDocument("Section1/topic1").findPosts(0, 10)>

first

Returns the first post in the topic.

Syntax:

first → post object

Returns:

The first post in this topic.

Example:

This code gets the first post in a topic and assigns it to a variable:

<#assign firstPost = liquidsite.findDocument("Section1/topic1").first>

last

Returns the last post in the topic.

Syntax:

last → post object

Returns:

The last post in this topic.

Example:

This code gets the last post in a topic and assigns it to a variable:

<#assign lastPost = liquidsite.findDocument("Section1/topic1").last>

locked

Returns the topic locked flag.

Syntax:

locked → boolean

Returns:

The topic locked flag.

Example:

This code checks whether a topic is locked:

<#if topic1.locked>

postCount

Returns the number of posts in this topic.

Syntax:

postCount → number

Returns:

The number os posts in this topic.

Example:

This code loops through all posts in a topic:

<#list topic1.findPosts(0, topic1.postCount)>

subject

Returns the topic subject.

Syntax:

subject → string

Returns:

The topic subject.

Example:

This code outputs the subject of the first topic in "topic1":

<#assign topic = forum1.first>
<p>The topic subject is ${topic.subject}.</p>

Which will result in something like:

The topic subject is Welcome to the Liquid Site forum.


subjectSource

Returns the unprocessed topic subject.

Syntax:

subjectSource → string

Returns:

The unprocessed topic subject.

Example:

This code outputs the unprocessed subject of the first topic in "topic1":

<#assign topic = forum1.first>
<p>The topic subject is ${topic.subjectSource}.</p>

Which will result in something like:

The topic subject is <p>Welcome to the Liquid Site forum</p>.


created

Returns the topic created date.

Syntax:

created → date

Returns:

The topic created date.

Example:

This code outputs the topic created date:

<#assign topic = liquidsite.findDocument("Section1/topic1")>
<p>The topic created date is ${topic.created}.</p>

Which will result in something like:

The topic created date is 2005-01-15.


date

Returns the topic revision date.

Syntax:

date → date

Returns:

The topic revision date.

Example:

This code outputs the topic revision date:

<#assign topic = liquidsite.findDocument("Section1/topic1")>
<p>The topic revision date is ${topic.date}.</p>

Which will result in something like:

The topic revision date is 2005-01-21.


id

Returns the topic id.

Syntax:

id → number

Returns:

The topic id.

Example:

This code outputs the topic id:

<#assign topic = liquidsite.findDocument("Section1/topic1")>
<p>The topic id is ${topic.id}.</p>

Which will result in something like:

The topic id is 123.


lock

Returns the topic lock object.

Syntax:

lock → lock object

Returns:

The topic lock object.

Example:

This code gets the lock object of a topic and stores it in a variable:

<#assign lock = liquidsite.findDocument("Section1/topic1").lock>

name

Returns the topic name.

Syntax:

name → string

Returns:

The topic name.

Example:

The following code outputs the first topic name:

<#assign topic = liquidsite.forum.first>
The topic name is ${topic.name}.

online

Returns the topic online flag.

Syntax:

online → boolean

Returns:

True if the topic is online, false otherwise.

Example:

This code gets the online flag of a topic and stores it in a variable:

<#assign online = liquidsite.findDocument("Section1/topic1").online>

parent

Returns the parent section of the topic.

Syntax:

parent → section object

Returns:

The parent section under which the topic is located.

Example:

This code gets the parent of a topic and stores it in a variable:

<#assign parent = liquidsite.findDocument("Section1/topic1").parent>

In this case the parent of "topic1" is "Section1".


path

Returns the topic path.

Syntax:

path → string

Returns:

The topic path.

Example:

This code outputs the path of a topic:

<#assign path = liquidsite.findDocument("Section1/topic1").path>
<p>The path of "topic1" is ${path}.</p>

The result will be:

The path of "topic1" is Section1/topic1.


revision

Returns the topic revision number.

Syntax:

revision → number

Returns:

The topic revision number, or zero (0) if the topic doesn't exist.

Example:

This code outputs the revision of a topic:

<#assign revision = liquidsite.findDocument("Section1/topic1").revision>
<p>The revision of "topic1" is ${revision}.</p>

The result will be something like:

The revision of "topic1" is 2.


user

Returns the topic revision author.

Syntax:

user → user object

Returns:

The topic revision author, or an empty user if the topic doesn't exist.

Example:

This code gets the revision author of a topic and assigns it to a variable:

<#assign user = liquidsite.findDocument("Section1/topic1").user>

hasAccess

Checks whether the current logged in user has a specified permission over the topic. See the document object for information about the allowed permission values.

Syntax:

hasAccess(permission) → boolean

Returns:

True if the current logged in user has the specified permission over the topic, false otherwise.

Example:

This code checks whether the current logged in user has read access to a topic:

<#if liquidsite.findDocument("Section1/topic1").hasAccess("read")>