Skip to content
View in the app

A better way to browse. Learn more.

JimiWikman.se

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Configure the way comments are listed

  • Owner

In the templates for your record, you will find a template named "Comments". In this template there is a snippet of code that display the comments list and in that snippet of code we can make some adjustments to how comments are show,

{{$commentCount=0; $timeLastRead = $record->timeLastRead(); $lined = FALSE;}}
				{{foreach $record->comments( NULL, NULL, 'date', 'asc', NULL, NULL, NULL, NULL, FALSE, isset( \IPS\Request::i()->showDeleted ) ) as $comment}}
					{{if !$lined and $timeLastRead and $timeLastRead->getTimestamp() < $comment->mapped('date')}}
						{{if $lined = TRUE and $commentCount}}
							<hr class="ipsCommentUnreadSeperator">
						{{endif}}
					{{endif}}
					{{$commentCount++;}}
					{$comment->html()|raw}
				{{endforeach}}
				{template="commentMultimod" app="core" group="global" params="$record"}

 

So in this snippet of code we want to look at this part:

{{foreach $record->comments( NULL, NULL, 'date', 'asc', NULL, NULL, NULL, NULL, FALSE, isset( \IPS\Request::i()->showDeleted ) ) as $comment}}

This snippet has a few variables that we can adjust to change the way our comments are shown. By default we see 'date' and 'asc' already defined. As you can see in the list below asc is the sorting order and date is what the list of comments are ordered by.

/**
	 * Get comments
	 *
	 * @param	int|NULL			$limit					The number to get (NULL to use static::getCommentsPerPage())
	 * @param	int|NULL			$offset					The number to start at (NULL to examine \IPS\Request::i()->page)
	 * @param	string				$order					The column to order by
	 * @param	string				$orderDirection			"asc" or "desc"
	 * @param	\IPS\Member|NULL	$member					If specified, will only get comments by that member
	 * @param	bool|NULL			$includeHiddenComments	Include hidden comments or not? NULL to base of currently logged in member's permissions
	 * @param	\IPS\DateTime|NULL	$cutoff					If an \IPS\DateTime object is provided, only comments posted AFTER that date will be included
	 * @param	mixed				$extraWhereClause		Additional where clause(s) (see \IPS\Db::build for details)
	 * @param	bool|NULL			$bypassCache			Used in cases where comments may have already been loaded i.e. splitting comments on an item.
	 * @param	bool				$includeDeleted			Include Deleted Comments
	 * @param	bool|NULL			$canViewWarn			TRUE to include Warning information, NULL to determine automatically based on moderator permissions.
	 * @return	array|NULL|\IPS\Content\Comment	If $limit is 1, will return \IPS\Content\Comment or NULL for no results. For any other number, will return an array.
	 */
	public function comments( $limit=NULL, $offset=NULL, $order='date', $orderDirection='asc', $member=NULL, $includeHiddenComments=NULL, $cutoff=NULL, $extraWhereClause=NULL, $bypassCache=FALSE, $includeDeleted=FALSE, $canViewWarn=NULL )
	{

By changing these variables, you can edit the way your comments behave. Since you do this in the templates, it means that you can have different templates for different databases that each have its own behavior.

Big shoutout to Nathan Explosion for helping with this one.
https://invisioncommunity.com/forums/topic/462944-no-setting-for-comment-order-or-am-i-blind/

 


View full record

  • Views 1.3k
  • Created
  • Last Reply

Featured Replies

No posts to show

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.