getRTImages
Последнее обновление not available | История страницы | Улучшить эту страницу | Сообщить о проблеме
Support the team building MODX with a monthly donation.
The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.
Backers
Budget
$204 per month—let's make that $500!
Learn moreОсновы¶
- Настройте Rich Text TV
- Установите getRTImages через Package Management
- Вызовите сниппет
- Оформите вывод чанком
- Редакторы загружают любое число изображений через Rich Text Editor, они выводятся на странице. Плохая разметка в TV не мешает, извлекаются только img.
Сценарий использования¶
Подходит для простых слайдшоу. Изображения на уровне ресурса, интерфейс знаком авторам контента. Rich Text Editor.
Есть gallery Extras с большими возможностями, но часто это «слишком много». MIGX обычно выбирают для такого, но нужна настройка. getRTImages проще объяснить. Чище в Resource Tree, чем вложенные Resources для картинок, для чего Resources не предназначены.
Это один из вариантов слайдшоу и галерей в MODX, выбирайте под задачу.
Как использовать¶
Examples¶
Вызов сниппета¶
[[getRTImages? &tv=`rich_text_TV` &tpl=`image_list_tpl`]]
Извлекает html img, атрибуты src, alt, title и data-index как плейсхолдеры в &tpl Chunk. По умолчанию до 10 изображений, меняется через &limit.
Template Chunk¶
<li><a href="[[+src]]" title="[[+title]]"><img src="[[+src]]" alt="[[+alt]]"></a></li>
Available Placeholders¶
[[+src]] |
Атрибут "src" элемента img. |
|---|---|
[[+alt]] |
Атрибут "alt"... |
[[+title]] |
Атрибут "title"... |
[[+index]] |
Значение атрибута из свойства "indexAttr". |
Properties¶
| Property | Description | Required? | Default |
|---|---|---|---|
| &id | ID ресурса для значения TV. | Yes | Current Resource: [[*id]] |
| &tv | Имя TV для извлечения изображений. | Yes | null (snippet will return nothing if not set) |
| &tpl | Чанк для вывода. | No | null (snippet will print an array of results) |
| &outputSeparator | Разделитель результатов. | No | PHP_EOL |
| &sort | Сортировка. See below for details. | No | ASC (php asort function) |
| &indexAttr | Атрибут для ключа index массива. | No | data-index |
| &limit | Лимит результатов. При dump в array игнорируется. | No | 10 |
Sort Options¶
| Property Value | PHP function | Behaviour |
|---|---|---|
| 'ASC' | asort() | The position of the elements in the array seems to affect priority of sorting using this method. As such, values are prioritized in this order: index, src, alt, title. Which means, when the "indexAttr" property is defined, and there are values in those attributes, those values will act as a "sort order index". This gives the end user or content author control over sorting by adding incremental values to the "data-index" attribute, for example. |
| 'DESC' | arsort() | Same as above but in reverse order. |
| 'natural' | natsort() | Although this is meant to sort items the way a human would do it, using it on an array (like we are) has unexpected results. This feature is experimental at best. |
| 'RAND' or 'random' | shuffle() | Random sorting. |
| '0' or null | DOM ordering | This will return results in the same order in which they appear in the source html. This is also an easy, intuitive way to give end users control over sort order. |
Дополнительные ресурсы¶
Support the team building MODX with a monthly donation.
The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.
Backers
Budget
$204 per month—let's make that $500!
Learn more










