Jump to content

[Bug 4.7.0] CMS database setting "Field Options > Records per page" controls also comments per page?


Go to solution Solved by Marc,

Recommended Posts

Posted (edited)

While I was looking into changing the number of comments per page for database records (see this link) I found out that IPS actually already allows to control it. The problem is that the number is tied to the setting that also controls the number of records shown per page.

The setting I'm talking about is "Field Options > Records per page" when editing a database settings. The name implies it controls the number of records, but at the same time it controls also the number of comments:

	/**
	 * Set custom posts per page setting
	 *
	 * @return int
	 */
	public static function getCommentsPerPage()
	{
		if ( ! empty( \IPS\cms\Databases\Dispatcher::i()->recordId ) )
		{
			$class = 'IPS\cms\Records' . static::$customDatabaseId;
			try
			{
				$record = $class::load( \IPS\cms\Databases\Dispatcher::i()->recordId );
				
				if ( $record->_forum_record and $record->_forum_comments and \IPS\Application::appIsEnabled('forums') )
				{
					return \IPS\forums\Topic::getCommentsPerPage();
				}
			}
			catch( \OutOfRangeException $e )
			{
				/* recordId is usually the record we're viewing, but this method is called on recordFeed widgets in horizontal mode which means recordId may not be __this__ record, so fail gracefully */
				return static::database()->field_perpage;
			}
		}
		else if( static::database()->forum_record and static::database()->forum_comments and \IPS\Application::appIsEnabled('forums') )
		{
			return \IPS\forums\Topic::getCommentsPerPage();
		}

		return static::database()->field_perpage;
	}

 

While simply changing the text to mention it controls also comments can be a fix, I would rather you add a separate setting that controls comments specifically. Without a new setting it would be impossible to keep showing 25 records per page but only 5 comments per page. You'd have to also show only 5 records per page. It's not ideal to have the same setting control both.

Edited by teraßyte
  • 1 year later...
  • Solution
Posted

This issue has been resolved in our recent 4.7.14 release of the platform. Please upgrade to resolve the issue, and if you see any further problems at that point, please let us know.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...