Перейти к публикации
View in the app

A better way to browse. Learn more.

Дизайн и модификация Invision Community

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.

список записей категории в записи

Опубликовано:

Почти похожее можно организовать блоком, выбрав там в плагинах Страница->Лента записи, и там дается выбор из какой категории выводить или из всех. Соответственно если применить такой метод то мне нужно будет уже внутри записи применять к этому блоку категорию из которой нужно вывести записи, что не возможно сделать, так как ни у кода {block='key'} нету дополнительных параметров, ни в шаблоне блока нельзя применять категорию. Как быть?

Хочу что-то типа:

Новость "Ccc" из категории "C1" находится в базе "C1", в ней нужно вывести список записей из категории "C2" базы "C2" и т.д. задать значение из какой категории будут выводиться эти записи нужно как-то кодом, внутри шаблона 'record', так как записей много метод вставки блока не подходит.

Более простым языком: вывести из заданной в переменной $cats категории список последних 5-10 записей.

Рекомендованные сообщения

Опубликовано:
  • Автор
$value = \IPS\cms\Records1::load(1);

загружает 1 запись из базы, а как загрузить все записи из базы?

Опубликовано:
{{$dbId = 1;}}
{{$recordsClass = '\IPS\cms\Records' . $dbId;}}
{{$records = $recordsClass::getItemsWithPermission( array( array( 'category_id=?', 2 ) ) );}}

1 - ID базы, из которой выводить записи

2 - ID категории, из которой выводить записи

  • 4 месяца спустя...
Опубликовано:
  • Автор
13.04.2020 в 10:21, newbie сказал:

{{$dbId = 1;}}
{{$recordsClass = '\IPS\cms\Records' . $dbId;}}
{{$records = $recordsClass::getItemsWithPermission( array( array( 'category_id=?', 2 ) ) );}}

1 - ID базы, из которой выводить записи

2 - ID категории, из которой выводить записи

А как мне выгрузить допустим только 5 самых новых записей? Просто я думаю, что если выгрузить разом несколько тысяч записей в переменную и потом её разбирать переменная просто лопнет

Опубликовано:

Смотрите метод getItemsWithPermission

	/**
	 * Get items with permission check
	 *
	 * @param	array		$where				Where clause
	 * @param	string		$order				MySQL ORDER BY clause (NULL to order by date)
	 * @param	int|array	$limit				Limit clause
	 * @param	string|NULL	$permissionKey		A key which has a value in the permission map (either of the container or of this class) matching a column ID in core_permission_index or NULL to ignore permissions
	 * @param	mixed		$includeHiddenItems	Include hidden items? NULL to detect if currently logged in member has permission, -1 to return public content only, TRUE to return unapproved content and FALSE to only return unapproved content the viewing member submitted
	 * @param	int			$queryFlags			Select bitwise flags
	 * @param	\IPS\Member	$member				The member (NULL to use currently logged in member)
	 * @param	bool		$joinContainer		If true, will join container data (set to TRUE if your $where clause depends on this data)
	 * @param	bool		$joinComments		If true, will join comment data (set to TRUE if your $where clause depends on this data)
	 * @param	bool		$joinReviews		If true, will join review data (set to TRUE if your $where clause depends on this data)
	 * @param	bool		$countOnly			If true will return the count
	 * @param	array|null	$joins				Additional arbitrary joins for the query
	 * @param	mixed		$skipPermission		If you are getting records from a specific container, pass the container to reduce the number of permission checks necessary or pass TRUE to skip container-based permission. You must still specify this in the $where clause
	 * @param	bool		$joinTags			If true, will join the tags table
	 * @param	bool		$joinAuthor			If true, will join the members table for the author
	 * @param	bool		$joinLastCommenter	If true, will join the members table for the last commenter
	 * @param	bool		$showMovedLinks		If true, moved item links are included in the results
	 * @return	\IPS\Patterns\ActiveRecordIterator|int
	 */
	public static function getItemsWithPermission( $where=array(), $order=NULL, $limit=10, $permissionKey='read', $includeHiddenItems=\IPS\Content\Hideable::FILTER_AUTOMATIC, $queryFlags=0, \IPS\Member $member=NULL, $joinContainer=FALSE, $joinComments=FALSE, $joinReviews=FALSE, $countOnly=FALSE, $joins=NULL, $skipPermission=FALSE, $joinTags=TRUE, $joinAuthor=TRUE, $joinLastCommenter=TRUE, $showMovedLinks=FALSE )
	{{$records = $recordsClass::getItemsWithPermission( array( array( 'category_id=?', 2 ) ), NULL, 5 );}}

 

Создайте аккаунт или войдите в него для комментирования

Сейчас на странице 0

  • Нет пользователей, просматривающих эту страницу.

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.