pdoNeighbors + ms2Gallery

Здравствуйте уважаемые разработчики и пользователи MODx!

Подскажите неопытному:
— пытаюсь вывести навигацию по ресурсам с изображением превью (small) ms2Gallery. Перерыл весь сайт, нашёл примеры только с miniShop2, но как подружить с ms2Gallery сам не разберусь.

Вот один из моих вариантов, но он как и все не работает:
{'!pdoNeighbors' | snippet : [
    'snippet' => 'ms2GalleryResources',
    'sortby' => 'publishedon',
    'sortdir' => 'ASC',
    'leftJoin' => '{ "thumbs": { "class":"msResourceFile","alias":"thumbs", "on": "thumbs.id = modResource.id" }}',
    'select' => '{ "thumbs":"thumbs.thumb as small" }',
    'tplWrapper' => '@INLINE {$prev}{$next}',
    'tplPrev' => '@INLINE <a href="/{$uri}"><img src="{$small}"></a>',
    'tplNext' => '@INLINE <a href="/{$uri}"><img src="{$small}"></a>'
]}
Прошу Вашей помощи!
Илья
06 июня 2020, 11:34
modx.pro
829
0

Комментарии: 6

Илья
08 июня 2020, 10:30
0
Други! Помогите!
В доках к pdoNeighbors есть пример, и тоже с miniShop2:
{'!pdoNeighbors' | snippet : [
    'snippet' => 'msProducts',
    'sortby' => 'publishedon',
    'sortdir' => 'ASC',
    'leftJoin' => '{ "thumbs": { "class":"msProductData","alias":"thumbs", "on": "thumbs.id = modResource.id" }}',
    'select' => '{ "thumbs":"thumbs.thumb as small" }',
    'tplWrapper' => '@INLINE {$prev}',
    'tplPrev' => '@FILE chunks/product/item_prev.tpl',
]}
Сам не могу разобраться. перепробовал всё!
    Илья
    17 июня 2020, 18:18
    0
    Апну свой вопрос с выводом ошибки
    Мне нужно вывести первую картинку {$small} из галереи ms2gallery в предыдущие и следующие документы
    Вывожу вот так:
    {'!pdoNeighbors' | snippet : [
        'loadModels' => 'ms2gallery',
        'class' => 'msResourceFile',
        'sortdir' => 'ASC',
        'where' => '{"parent":0,"resource_id":'~ $id ~',"active":1,"rank:IN":[ 1 ]}',
        'leftJoin' => '{
                            		"Resource": {
                               			"class": "modResource",
                               			"on": "msResourceFile.resource_id = Resource.id"
                              		},
                           			"small":{
                            			"class":"msResourceFile", 
                            			"alias":"small", 
                        				"on":"small.parent=msResourceFile.id AND small.path LIKE \'%/small/\'"
                           			}
            }',
        'select'		=> '{
                           		"msResourceFile":"*",
                           		"small":"small.url as small"
             }',
        'tplWrapper' => '@INLINE {$prev}{$next}',
        'tplPrev' => '@INLINE <a href="/{$uri}"><img src="{$small}">туда</a>',
        'tplNext' => '@INLINE <a href="/{$uri}"><img src="{$small}">сюда</a>',
        'showLog'      	=> '1'
    ]}
    А вот showLog (ругается на синтаксис):
    0.0000372: Loaded model "ms2gallery" from "/core/components/ms2gallery/model/"
    0.0000250: pdoTools loaded
    0.0011430: Found ids of neighbors: ,6
    0.0000188: Conditions prepared
    0.0000060: Query parameters ready
    0.0000298: Loaded model "ms2gallery" from "/core/components/ms2gallery/model/"
    0.0000122: xPDO query object created
    0.0000470: leftJoined modResource as Resource
    0.0000401: leftJoined msResourceFile as small
    0.0000920: Added selection of modResource: `id`, `type`, `contentType`, `pagetitle`, `longtitle`, `description`, `alias`, `alias_visible`, `link_attributes`, `published`, `pub_date`, `unpub_date`, `parent`, `isfolder`, `introtext`, `content`, `richtext`, `template`, `menuindex`, `searchable`, `cacheable`, `createdby`, `createdon`, `editedby`, `editedon`, `deleted`, `deletedon`, `deletedby`, `publishedon`, `publishedby`, `menutitle`, `donthit`, `privateweb`, `privatemgr`, `content_dispo`, `hidemenu`, `class_key`, `context_key`, `content_type`, `uri`, `uri_override`, `hide_children_in_tree`, `show_in_tree`, `properties`
    0.0000319: Added selection of msResourceFile: `id`, `resource_id`, `source`, `parent`, `name`, `alt`, `description`, `add`, `path`, `file`, `type`, `createdon`, `createdby`, `rank`, `url`, `properties`, `hash`, `active`
    0.0000041: Added selection of msResourceFile: small.url as small
    0.0000460: Added where condition: 0=, 1=6
    0.0000179: Sorted by menuindex, ASC
    0.0001101: SQL prepared "SELECT `modResource`.`id`, `modResource`.`type`, `modResource`.`contentType`, `modResource`.`pagetitle`, `modResource`.`longtitle`, `modResource`.`description`, `modResource`.`alias`, `modResource`.`alias_visible`, `modResource`.`link_attributes`, `modResource`.`published`, `modResource`.`pub_date`, `modResource`.`unpub_date`, `modResource`.`parent`, `modResource`.`isfolder`, `modResource`.`introtext`, `modResource`.`content`, `modResource`.`richtext`, `modResource`.`template`, `modResource`.`menuindex`, `modResource`.`searchable`, `modResource`.`cacheable`, `modResource`.`createdby`, `modResource`.`createdon`, `modResource`.`editedby`, `modResource`.`editedon`, `modResource`.`deleted`, `modResource`.`deletedon`, `modResource`.`deletedby`, `modResource`.`publishedon`, `modResource`.`publishedby`, `modResource`.`menutitle`, `modResource`.`donthit`, `modResource`.`privateweb`, `modResource`.`privatemgr`, `modResource`.`content_dispo`, `modResource`.`hidemenu`, `modResource`.`class_key`, `modResource`.`context_key`, `modResource`.`content_type`, `modResource`.`uri`, `modResource`.`uri_override`, `modResource`.`hide_children_in_tree`, `modResource`.`show_in_tree`, `modResource`.`properties`, `msResourceFile`.`id`, `msResourceFile`.`resource_id`, `msResourceFile`.`source`, `msResourceFile`.`parent`, `msResourceFile`.`name`, `msResourceFile`.`alt`, `msResourceFile`.`description`, `msResourceFile`.`add`, `msResourceFile`.`path`, `msResourceFile`.`file`, `msResourceFile`.`type`, `msResourceFile`.`createdon`, `msResourceFile`.`createdby`, `msResourceFile`.`rank`, `msResourceFile`.`url`, `msResourceFile`.`properties`, `msResourceFile`.`hash`, `msResourceFile`.`active`, small.url as small FROM `n3zho3y9lB8A_ms2_resource_files` AS `msResourceFile` LEFT JOIN `n3zho3y9lB8A_site_content` `Resource` ON msResourceFile.resource_id = Resource.id LEFT JOIN `n3zho3y9lB8A_ms2_resource_files` `small` ON small.parent=msResourceFile.id AND small.path LIKE '%/small/' WHERE `modResource`.`id` IN (,6) ORDER BY menuindex ASC "
    0.0002079: Could not process query, error #1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '6) ORDER BY menuindex ASC' at line 1
    0.0001562: Chunks processed
    0.0021551: Total time
    2 097 152: Memory usage
    Не могу расшифровать ошибку:
    Could not process query, error #1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '6) ORDER BY menuindex ASC' at line 1
      Илья
      14 июля 2020, 13:15
      1
      0
      Сделал так:
      {'!pdoNeighbors' | snippet : [
          'class' => 'modResource',
              'loadModels' => 'ms2gallery',
              'leftJoin' => [
                  'Image' => [
                      'class' => 'msResourceFile',
                      'on' => 'modResource.id = Image.resource_id AND Image.parent = 0 AND Image.rank = 0',
                  ],
                  'Thumb' => [
                      'class' => 'msResourceFile',
                      'on' => 'Image.id = Thumb.parent AND Thumb.path LIKE "%small%"',
                  ]
              ],
              'select' => [
                  'modResource' => '*',
                  'Thumb' => 'Thumb.url as small',
              ],
          'tplWrapper' => '@INLINE {$prev}{$next}',
          'tplPrev' => '@INLINE <a href="/{$uri}"><img src="{$small}">туда</a>',
          'tplNext' => '@INLINE <a href="/{$uri}"><img src="{$small}">сюда</a>',
      ]}
      В результате выводится первая миниатюра {$small} в pdoNeighbors
      Может кому-то будет полезно.

      Не дадим modxУ погибнуть!!!
        Иван Бочкарев
        05 ноября 2020, 21:31
        +1
        Приложите, пожалуйста, скриншот как выглядит на фронте. В доку перенесем
          Олег Щавелев
          08 ноября 2020, 12:45
          0
          Я поддерживаю. Нужно собирать успешные кейсы.
          Диман
          01 июня 2022, 06:06
          0
          В результате выводится первая миниатюра {$small}
          Подскажите пожалуйста, как вывести оригинал изображения, а не превьюшку
          Авторизуйтесь или зарегистрируйтесь, чтобы оставлять комментарии.
          6