Не сортирует ресурсы по тегу через where и OR, как исправить?

Выводит все ресурсы вместо сортировки и вывода, tagsWhere выдаёт правильную строку такую:
{"tags:LIKE","%роллы%","OR:tags:LIKE","%кексы%","OR:tags:LIKE","%рофлы%"}
tags это «Авто-метка» пакет tagLister

Такие ресурсы с такими тегами есть
[[!pdoResources?
	&parents=`6`
	&resources=`-[[*id]]`
	&includeTVs=`tags,newsImg`
	&sortby=`{ "parent":"ASC", "menuindex":"ASC" }`
	&tpl=`similarNewsTpl`
	&where=`[[!tagsWhere? &input=`[[*tags]]`]]`
]]
Vladimir
16 февраля 2022, 13:27
modx.pro
1
484
0

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

Vladimir
16 февраля 2022, 13:33
0
Выводит все, ресурсы, даже в которых нет тега, если уберу parents то выводит все ресурсы в контексте
    Роман
    16 февраля 2022, 14:29
    0
    Добавьте &showLog=`1` и посмотрите, свой запрос.
      Vladimir
      17 февраля 2022, 07:36
      0
      Лог такой
      0.0001030: pdoTools loaded
      0.0000339: xPDO query object created
      0.0008740: Included list of tvs: newsImg, tags
      0.0001979: leftJoined modTemplateVarResource as TVnewsimg
      0.0001509: leftJoined modTemplateVarResource as TVtags
      0.0002151: Added selection of modResource: `id`, `type`, `contentType`, `pagetitle`, `longtitle`, `description`, `alias`, `alias_visible`, `link_attributes`, `published`, `pub_date`, `unpub_date`, `parent`, `isfolder`, `introtext`, `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.0000110: Added selection of modTemplateVarResource: IFNULL(`value`, '') AS `tv.newsImg`
      0.0000069: Added selection of modTemplateVarResource: IFNULL(`value`, '') AS `tv.tags`
      0.0000110: Replaced TV conditions
      0.0013409: Processed additional conditions
      0.0025702: Added where condition: 0=, modResource.id:NOT IN(7), modResource.parent:IN(6,7,39,40,41,42,43,44), modResource.published=1, modResource.deleted=0
      0.0000100: Replaced TV conditions
      0.0001101: Sorted by modResource.parent, ASC
      0.0001791: Sorted by modResource.menuindex, ASC
      0.0000038: Limited to 10, offset 0
      0.0006480: 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`.`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`, IFNULL(`TVnewsimg`.`value`, '') AS `tv.newsImg`, IFNULL(`TVtags`.`value`, '') AS `tv.tags` FROM `modx_site_content` AS `modResource` LEFT JOIN `modx_site_tmplvar_contentvalues` `TVnewsimg` ON `TVnewsimg`.`contentid` = `modResource`.`id` AND `TVnewsimg`.`tmplvarid` = 54 LEFT JOIN `modx_site_tmplvar_contentvalues` `TVtags` ON `TVtags`.`contentid` = `modResource`.`id` AND `TVtags`.`tmplvarid` = 56 WHERE  ( `modResource`.`id` NOT IN (7) AND `modResource`.`parent` IN (6,7,39,40,41,42,43,44) AND `modResource`.`published` = 1 AND `modResource`.`deleted` = 0 )  ORDER BY modResource.parent ASC, modResource.menuindex ASC LIMIT 10 "
      0.0011370: SQL executed
      0.0000699: Rows fetched
      0.0072129: Prepared and processed TVs
      0.0013368: Loaded "modChunk" with name "similarNewsTpl"
      0.0034480: Compiled Fenom chunk with name "modchunk/109"
      0.0051410: Returning processed chunks
      0.0188210: Total time
      4 194 304: Memory usage
      Все новости
        Роман
        17 февраля 2022, 10:19
        0
        Видел, что ты решил уже проблему, но в с логах нет твоего условия. Значит сниппет работает не корректно.
        Vladimir
        17 февраля 2022, 07:39
        0
        Когда пишу вручную where
        &where=`{"tags: LIKE": "%asd%"}`
        Страница становится белой, а в логе это
        line 69, near '{"tags: LIKE":' <- there
        Почему так неизвестно, неделю назад делал так же, всё работало
          Vladimir
          17 февраля 2022, 08:01
          0
          А если написать на феноме в ручную так
          {'!pdoResources' | snippet  : [
              'parents' => '6',
              'showLog' => '1',
              'tpl' => 'similarNewsTpl',
              'includeTVs' => 'tags,newsImg',
              'where' => ['tags:LIKE' => '%asd%']
          ]}
          То фильтрует, но если я засуну допустим снипет сюда, и снипет вернет array
          то ничего не ищет
          <?php
          $tags = explode(",", $input);
          $output = array();
          
          $idx = 0;
          foreach($tags as $tag){
              if($idx == 0){
                  array_push($output,'tags:LIKE','%'.$tag.'%');
              } else {
                  array_push($output,'OR:tags:LIKE','%'.$tag.'%');
              }
              
              $idx++;
          }
          
          return $output;
          Вызов такой
          {set $wh = '!tagsWhereV2' | snippet : ['input' => $_modx->resource.tags]}
          ,
          {'!pdoResources' | snippet  : [
              'parents' => '6',
              'showLog' => '1',
              'tpl' => 'similarNewsTpl',
              'includeTVs' => 'tags,newsImg',
              'where' => $wh
          ]}
          При этом лог одинаковый, и там и там стоит where и написано что сортирует, вывод оди и тот же, но как я наврено понял бед в том что это снипет, можно как-то внутри странице на самом fenome написать это список?
          Vladimir
          17 февраля 2022, 08:27
          0
          Да беда в том что это был сниппет, почему хз.
          История начинается так
          {var $tagsArray = $_modx->resource.tags | split}
          {set $idx = 0}
          [{foreach $tagsArray as $tag}{if $idx == 0}'tags:LIKE' => '%{$tag}%'{else},'OR:tags:LIKE' => '%{$tag}%'{/if}{set $idx = $idx + 1}{/foreach}]
          После того как поставил этот форыч в where пришлось идти плакать, потому что я сделал бред, и получил белую страницу, но потом таки сделал

          {var $tagsArray = $_modx->resource.tags | split}
          {set $newTagsArray = []}
          {set $newIdx = 0}
          
          {foreach $tagsArray as $tag}
              {if $newIdx == 0}
                  {set $newTagsArray['tags:LIKE'] = '%' ~ $tag ~ '%'}
              {else}
                  {set $newTagsArray['OR:tags:LIKE'] = '%' ~ $tag ~ '%'}
              {/if}
              {set $newIdx = $newIdx + 1}        
              
          {/foreach}
          
          {'!pdoResources' | snippet  : [
              'parents' => '6',
              'tpl' => 'similarNewsTpl',
              'includeTVs' => 'tags,newsImg',
              'where' => $newTagsArray
          ]}
          И всё заработало, всё сортирует, теперь не нужно устанавливать ещё 2 доп плагина чтобы tagLister работал, да и бывают случаи подобные, где нужно получить всё из всего, а через сниппет не работает, если генерировать там where

          Хотя я получается зря мучался, ведь мог сделал всё в снипете сразу, и просто получить вывод
            Роман
            17 февраля 2022, 10:20
            0
            Что передается в [[*tags]]?
              Vladimir
              17 февраля 2022, 12:31
              0
              тэг, тэг, тэг
            Авторизуйтесь или зарегистрируйтесь, чтобы оставлять комментарии.
            9