Финансовая поддержка VPS, бесплатные дополнения и docs Донаты оплачивают сервер и двигают бесплатные дополнения MODX и документацию. Поддержать

Всего 126 115 комментариев

Алексей Смирнов
Алексей Смирнов
'where' => [0 => "0 < FIND_IN_SET(" ~ $_modx->resource.id~ ", replace(`TVportfolio_item`.`value`, '||', ','))"]
Тут $_modx->resource.id — id текущего ресурса (тот к которому будем искать в сторонних ресурсах значения в ТВ-шке portfolio_item, внимательно смотрите на особенности записи ТВ в запросах where.
Егор
Егор
Там это отдельное поле «Теги» (список автодополнение).
В том то и дело, что все используют какие-то свистелки и… к тегам, а обычный, классический способ для zoomx нигде не написан. Я написал автору дополнения, вряд ли он ответит, конечно, но вдруг.
На счет коммерческого предложения, спасибо, откажусь. Потому что во-первых, нищеброд, а во-вторых, делаю не коммерческий сайт для себя, типа как хобби о рыбалке. Спасибо за ваш ответ!
Алексей
Алексей
Добрый день.
Делал вот на этом сайте
АнтикМагаз. Там называются метки товаров. Там это отдельное поле «Теги» (список автодополнение). Если надо, напишу как.
Вот здесь описывал Облако тегов для miniShop2
Илья
Илья
Посмотрите пожалуйста:
Не могу разобраться, ругается на синтаксис. У меня сайт на fenom. В стандартной транскрипции работает, а в fenom выдаёт ошибку. Всё перепробовал, в глазах рzбит.

Работает:

[[!ms2GalleryResources?
    &tpl=`proekt-item-portfolio`
    &parents=`394`
    &limit=`6`
    &where=`["1 = 1 AND FIND_IN_SET('[[*portfolio_item]]', replace(portfolio_item, '||', ','))"]`
    &includeThumbs=`medium`
    &includeTVs=`portfolio_item`
    &depth=`0`
    &showLog=`1`
]]

Не работает:

{'!ms2GalleryResources' | snippet : [
    'tpl' => 'proekt-item-portfolio'
    'parents' => '394'
    'limit' => '6'
    'where' => ["1 = 1 AND FIND_IN_SET("~$_modx->resource.portfolio_item~", replace(portfolio_item, '||', ','))"],
    'includeThumbs' => 'medium'
    'includeTVList' => 'portfolio_item'
    'depth' => '0'
    'showLog' => '1'
]}
showLog:
0.0000520: Loaded model "ms2gallery" from "/core/components/ms2gallery/model/"
0.0000269: pdoTools loaded
0.0000110: xPDO query object created
0.0002151: Included list of tvs: portfolio_item
0.0000780: leftJoined msResourceFile as medium
0.0000532: leftJoined modTemplateVarResource as TVportfolio_item
0.0000861: 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.0000072: Added selection of msResourceFile: `url` as `medium`,`name` as `medium.name`,`description` as `medium.description`,`createdon` as `medium.createdon`,`createdby` as `medium.createdby`,`properties` as `medium.properties`,`alt` as `medium.alt`,`add` as `medium.add`
0.0000041: Added selection of modTemplateVarResource: IFNULL(`value`, '') AS `tv.portfolio_item`
0.0000072: Replaced TV conditions
0.0004930: Processed additional conditions
0.0005889: Added where condition: 0=1 = 1 AND FIND_IN_SET(Блок-контейнеры, replace(`TVportfolio_item`.`value`, '||', ',')), modResource.parent:IN(394), modResource.published=1, modResource.deleted=0
0.0000019: Replaced TV conditions
0.0000300: Sorted by modResource.publishedon, DESC
0.0000010: Limited to 6, offset 0
0.0001161: 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`, `medium`.`url` as `medium`, `medium`.`name` as `medium.name`, `medium`.`description` as `medium.description`, `medium`.`createdon` as `medium.createdon`, `medium`.`createdby` as `medium.createdby`, `medium`.`properties` as `medium.properties`, `medium`.`alt` as `medium.alt`, `medium`.`add` as `medium.add`, IFNULL(`TVportfolio_item`.`value`, '') AS `tv.portfolio_item` FROM `kfsz8k4f2Ra7_site_content` AS `modResource` LEFT JOIN `kfsz8k4f2Ra7_ms2_resource_files` `medium` ON `medium`.`resource_id` = `modResource`.`id` AND `medium`.`parent` != 0 AND `medium`.`path` LIKE '%/medium/%' AND `medium`.`active` = 1 AND `medium`.`rank` = 0 LEFT JOIN `kfsz8k4f2Ra7_site_tmplvar_contentvalues` `TVportfolio_item` ON `TVportfolio_item`.`contentid` = `modResource`.`id` AND `TVportfolio_item`.`tmplvarid` = 19 WHERE  ( 1 = 1 AND FIND_IN_SET(Блок-контейнеры, replace(`TVportfolio_item`.`value`, '||', ',')) AND `modResource`.`parent` IN (394) AND `modResource`.`published` = 1 AND `modResource`.`deleted` = 0 )  ORDER BY modResource.publishedon DESC LIMIT 6 "
0.0002279: 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 'Блок-контейнеры, replace(`TVportfolio_item`.`value`, '||', ',')) AND `modResource`.`pa' at line 1
0.0015500: Total time
2 097 152: Memory usage
Сергей
Сергей
Может кто сталкивался с подобной проблемой, у меня не создаются блоки на главной странице, на внутренних работает все прекрасно.
Ошибка при заходе на страницу: assets/components/pageblocks/connector.php 500 (Internal Server Error) ext-base.js 21

Изначально вроде работало, сейчас не могу понять в чем причина.

И это еще как-то связанно с типом ресурса, если выбрать не Документ а статический ресурс, то ошибка пропадает.
Павел Романов
Павел Романов
Сделайте сниппет getTags:
<?php
$id = $modx->getOption('id', $scriptProperties, $modx->resource->get('id'));
$table = $modx->getOption('table_prefix').'ms2_products';
if($query = $modx->query("SELECT * FROM {$table} WHERE id = {$id}")){
	$prod = $query->fetch(PDO::FETCH_ASSOC);
	$tags = json_decode($prod['tags'], 1);
	foreach($tags as $tag){
	    $out .= $modx->getChunk($tpl, array('tag' =>  $tag));
	}
}
return $out;

Вызывайте:
[[getTags? &tpl=`tag_tpl`]]

Если не на странице товара, указывайте &id:
[[getTags? &id=`[[+id]]` &tpl=`tag_tpl`]]

Чанк tag_tpl:
<a href="/search/?[[+tag]]" class="some-class">[[+tag]]</a>
Егор
Егор
Да, спасибо! Оно.
Нужно было создать файл «modifier.field.php» и положить его в папку:
«core/components/zoomx/smarty/plugins/» и все заработало.

Содержимое файла «modifier.field.php»:
<?php
/*
 * Smarty plugin
 * -------------------------------------------------------------
 * Файл:    modifier.field.php
 * Тип:     modifier
 * Имя:     field
 * Назначение:  Get a field of the specified resource.
 * -------------------------------------------------------------
 */
function smarty_modifier_field($id, $field)
{
    global $modx;

    $id = (int)$id;
    if ($id && $resource = $modx->getObject('modResource', ['id' => $id])) {
        return $resource->{$field};
    }

    return null;
}

или

<?php
// Плагин
// Событие OnModxInit

if ($modx->context->key !== 'mgr') {
    function fieldModifier($id, $field)
    {
        global $modx;
    
        $id = (int)$id;
        if ($id && $resource = $modx->getObject('modResource', ['id' => $id])) {
            return $resource->{$field};
        }
    
        return null;
    }

    // Регистрируем функцию модификатора
    $smarty = parserx();
    $smarty->registerPlugin("modifier","field", "fieldModifier");
}

(продублирую на всякий случай)

{5|field:"pagetitle"}
// Можно вернуть дефолтное значение
{5|field:"pagetitle"|default:"Ресурс не найден!"}
svvtx
svvtx
Алексей Смирнов
Алексей Смирнов
Вы мешаете синтаксис фенома и phx MODX.
Запишите все на феноме для начала:
{var $output = 'ms2GalleryResources' | snippet: [
    'tpl' => 'proekt-item-portfolio',
    'parents' => '394',
    'where' => '{ "connection:=":"'~$_modx->resource.connection~'","connection:!=":"1"}',
    'limit' => '6',
    'includeThumbs' => 'medium',
    'includeTVList' => 'days, connection, video',
    'depth' => '0',
    'showLog' => '1'
]}
{if $output}
<h3 class="text-center">{$_modx->resource.connection} в наличии</h3>
<div class="row flex-content-center">
{$output}
</div>
{/if}
и если не сработает можно двигаться дальше.
например у вас гарантированно в ТВ поле connection Находится один id? те там нет двух или трех id через запятую?