Сергій

Сергій

Был в сети 04 августа 2024, 02:33
Заказы принимаю
Спасибо за совет. Уже написал код который одним запросом собирает все.
Вот что получаю:
[
{
   "id": "ID ресурса",
   "pagetitle": "Название товара",
   "product_article": "TV артикул",
   "product_id": "TV айди товара",
   "parent_pagetitle": "Название каталога где лежит товар",
   "price": "TV цена товара",
   "published": "1", - ну и так понятно. 
   "url": "https://site.com/?a=resource/update&id=ID ресурса" - ссылка для менеджеров чтобы перейти в товар
}
]
Привет еще раз. Можешь подсказать как сделать так чтобы выводило только 1 значение. modx.pro/help/22379 хочу настроить сортировку. Нужно чтобы просто вернуло одно значение.
<?php
$output = $input;
$value = $input;
if (isset($options)){
  $tvname = $options;
  $query = $modx->newQuery('manufacturer',array('name'=>$tvname));
  $query->select('elements');
  $query->prepare();
  if ($query->prepare() && $query->stmt->execute()) {
    $row = $query->stmt->fetch(PDO::FETCH_ASSOC);
  }
  $elements = explode('||',$row['elements']);
  foreach($elements as $key => $el){
    $el = explode('==',$el);
    if(count($el)>1){
      if($el[1] == $value){
        $output = $el[0];
      }
    }
  }
}
return $output;
Просто возвращает айди. А нужно название. Спасибо.
[[!pdoPage?
              &element=`pdoResources`
              &parents=`[[!BabelTranslation? &contextKey=`[[*context_key]]` &resourceId=`66`]], [[BabelTranslation? &contextKey=`[[*context_key]]` &resourceId=`70`]], [[BabelTranslation? &contextKey=`[[*context_key]]` &resourceId=`68`]], [[BabelTranslation? &contextKey=`[[*context_key]]` &resourceId=`243`]]`
              &hideContainers=`1`
              &includeContent=`1`
              &useWeblinkUrl=`1`
              &limit=`24`
              &setMeta=`0`
              &sortdir=`DESC`
              &sortby=`menuindex`
              &tpl=`portfolio-tpl`
              &tvFilters=`
              [[++cultureKey:is=`[[++cultureKey]]`:then=`[[*id:is=`[[BabelTranslation? &contextKey=`[[*context_key]]` &resourceId=`14`]]`:then=`category-portfolio==%category1%||category-portfolio==%category2%||category-portfolio==%category3%||category-portfolio==%category4%`]]`]]
              [[++cultureKey:is=`[[++cultureKey]]`:then=`[[*id:is=`[[BabelTranslation? &contextKey=`[[*context_key]]` &resourceId=`66`]]`:then=`category-portfolio==%category1%`:else=``]]`]]
              [[++cultureKey:is=`[[++cultureKey]]`:then=`[[*id:is=`[[BabelTranslation? &contextKey=`[[*context_key]]` &resourceId=`70`]]`:then=`category-portfolio==%category2%`:else=``]]`]]
              [[++cultureKey:is=`[[++cultureKey]]`:then=`[[*id:is=`[[BabelTranslation? &contextKey=`[[*context_key]]` &resourceId=`68`]]`:then=`category-portfolio==%category3%`:else=``]]`]]
              [[++cultureKey:is=`[[++cultureKey]]`:then=`[[*id:is=`[[BabelTranslation? &contextKey=`[[*context_key]]` &resourceId=`243`]]`:then=`category-portfolio==%category4%`:else=``]]`]]
              `
              &includeTVs=`portfolio-images, portfolio-gallery`
              &tplPage=`@INLINE 
              <li class="page-item">
                <a class="page-link" href="[[+href]]">[[+pageNo]]</a>`
                &tplPageWrapper=`@INLINE 
                <nav aria-label="Page navigation example">
                  <ul class="pagination">[[+first]][[+prev]][[+pages]][[+next]][[+last]]</ul>
                </nav>
                `
                &tplPageActive=`@INLINE 
              <li class="page-item active"><a class="page-link" href="[[+href]]">[[+pageNo]]</a></li>
              `
              &tplPageFirst=``
              &tplPageLast=``
              &tplPagePrev=`@INLINE 
              <li class="page-item"><a class="page-link" href="[[+href]]"><i class="fas fa-chevron-left"></i></a></li>
              `
              &tplPageNext=`@INLINE 
              <li class="page-item"><a class="page-link" href="[[+href]]"><i class="fas fa-chevron-right"></i></a></li>
              `
              &tplPageSkip=`@INLINE 
              <li class="page-item"><a class="page-link" href="[[+href]]">[[%pdopage_right]]</a></li>
              `
              &tplPageFirstEmpty=``
              &tplPageLastEmpty=``
              &tplPagePrevEmpty=``
              &tplPageNextEmpty=``
              &loadModels=`UserFiles`
              &leftJoin=`{
              "File": {
              "class": "UserFile",
              "on": "File.parent = modResource.id AND File.rank = 0"
              },
              "Thumb": {
              "class": "UserFile",
              "on": "Thumb.parent = File.id AND Thumb.class = 'UserFile' AND Thumb.properties LIKE '%w\":400,\"h\":400%'"
              }
              }`
              &select=`{
              "modResource": "*",
              "Thumb": "Thumb.url as thumb"
              }`
              ]]
Вызывает копию ресурса с ID 648 почему так?
Спасибо за ответ. Но твой вариант не подходит. У меня в TV данные идут вот дак «1,2,55,5,22,222»
Подошел вот такой вариант:
&tvFilters=`user_id==%1%`
&where=`[«1 = 1 AND FIND_IN_SET('1', replace(user_id, '||', ','))»]`
Просто делаю на Modx revo полноценную CRM систему и нужно было реализовать вывод ресурсов под нужного пользователя.
Короче я баран, инфа 100%. Нужно было после вывода echo поставить exit();. А то мне верталась вся страница в ответе и само собой что ничего не работало. Спасибо что заставил меня логично посмотреть на свой же код.
Если кому то нужно юзайте мой код для добавления пользователей.