{lastdisc:item_id:count_item_itself}

Description

Returns the Unix timestamp of the most recent visible discussion comment on a given item. It queries the discussion table for the latest posting (state 0, meaning shown - hidden comments are ignored) on that item and returns its date as a plain integer timestamp. Pass the long (32-character hex) item ID, usually the current item. If the item has no visible comments, the result depends on the second parameter: by default it returns 0, but when count_item_itself is the literal string 1 it falls back to the item publish date instead (any other value, including 0, keeps the 0 result). With no item ID at all the result is 0. The raw timestamp is meant to be fed to date for display, or used as a sort key to surface the most recently discussed items. The matching field alias on a slice is usually defined as lastdisc of the item ID. Related: changed and changedate (item edit times), and the discussion module that stores the comments.

Parameters

item_id required default (none - required)

The long (32-character hex) ID of the item whose discussion comments to inspect, usually the current item. If missing or empty, the command returns 0.

count_item_itself optional default (empty)

Fallback flag, used only when the item has no visible comments. The literal string 1 makes the command return the item publish date instead of 0. Any other value (including 0 or empty) leaves the no-comment result at 0.

Examples

test[{lastdisc:5726c2c6b035d7aab450d1794e9e90d7:1}]
Expected[1775644745]
Actual[1775644745]
With the second argument set to the literal 1, an item that has no comments returns its own publish date (a Unix timestamp) instead of 0. Here the fixture item was published at 1775644745.
test{date:j.n.Y:{lastdisc:5726c2c6b035d7aab450d1794e9e90d7:1}}
Expected8.4.2026
Actual8.4.2026
The raw timestamp is meant to be fed to date for display. With the explicit numeric format j.n.Y the fixture publish date 1775644745 prints as a plain day.month.year.
test[{lastdisc:}]
Expected[0]
Actual[0]
With no item ID, the command returns 0 without touching the database.
virtual{item:{limit:{order:{ids:SLICE_ID}:_#LASTDISC:rnumeric}:0:5}:<li><a href="_#SEO_URL_">_#HEADLINE</a> {date:j.n.y:{_#LASTDISC}}</li>}
Expected(the five most recently discussed items, newest first)
The canonical real-world use: list the five most recently commented items. A slice field alias (here _#LASTDISC, defined as lastdisc of the item ID) supplies a per-item timestamp; order sorts by it (rnumeric = numeric, descending), limit keeps the top five, and item renders each. Replace SLICE_ID with your slice. Runtime-dependent, so shown for illustration.
test[{lastdisc:5726c2c6b035d7aab450d1794e9e90d7}]
Expected[0]
Actual[0]
An item with no visible discussion comments returns 0. This is the common case - the brackets just make the empty-looking result visible.
test[{lastdisc:5726c2c6b035d7aab450d1794e9e90d7:0}]
Expected[0]
Actual[0]
The fallback fires only when the second argument is exactly the string 1. Any other value - including 0 - leaves the no-comment result at 0.