Тодор

Тодор

Был в сети 29 июня 2026, 13:05
Заказы не принимаю
Как вариант
{switch $_modx->resource.id}
    {case 2}
        {set $filters = 'msoption|option1_1, ms|option1_2'}
        {set $aliases = 'msoption|option1_1==option1_1, ms|option1_2==option1_2'}
    {case 3}
        {set $filters = 'msoption|option2_1, ms|option2_2'}
        {set $aliases= 'msoption|option2_1==option2_1, ms|option2_2==option2_2'}
    {default}
        {set $filters = 'msoption|default_option1, ms|default_option2'}
        {set $aliases= 'msoption|default_option1==default_option1, ms|default_option2==default_option2'}
 {/switch}
{'!mFilter2' | snippet:[
    ...
    'filters' => $filters,
    'aliases' => $aliases,
    ...
    ]}
<?php
$id = 18; //ID ресурса

//Вариант 1
$coll = $modx->getCollection('modTemplateVarResource', array( 'contentid' => $id ));
if(!is_array($coll)) { return; }
foreach($coll as $tv){
    print_r($tv->toArray());
}

//Вариант 2
$query = $modx->newQuery('modTemplateVarResource');
$query->select(array('modTemplateVarResource.*'));
$query->where(array(
    '`modTemplateVarResource`.`contentid`' => $id
));
$query->sortby("id", "ASC");
$query->prepare();
print_r($query->toSQL());

$query->stmt->execute();
$rows = $query->stmt->fetchAll(PDO::FETCH_ASSOC);

foreach($rows as $row){
    print_r($row);
}
Не понимаю зачем менять эти значения еще раз веть значения для TV (type=checkbox) можно записать как val1==VAR1||val1==VAR2||val3==VAR2 где одна часть записываетьса в базу а другую часть видит клиент, не помню только какая часть и за что отвечает
{'!msProducts' | snippet:[
    'parents' => '5',
    'tpl'=> '@FILE chunks/middle_images.tpl',
    'leftJoin' => '{
        "images" : {
	    "class" : "msProductFile",
	    "on" : "`images`.product_id = msProduct.id AND `images`.type = \'image\' AND `images`.path NOT LIKE \'%x%\'"
	}
    }',
    'select' => '{
         "images" : "GROUP_CONCAT(`images`.`url` SEPARATOR \';\') as `images`"
    }',
]}
В самом чанке все картинки будут в строке с разделителем ";"
{set $imgArr = $images | split: ';'}
{foreach $imgArr  as $fileSrc}
    <img src="{$fileSrc}" srcset="{$fileSrc} 2x">
{/foreach}
Здесь выводятся оригиналы, для других превью меняешь/добавляешь leftJoin и select
Не знаю на сколько такая структура короче ))) но я бы так написал
{if in_array($_modx->resource.id, [17, 358]) ||
    in_array($_modx->resource.parent, $_modx->getChildIds(17,2)) ||
    in_array($_modx->resource.parent, $_modx->getChildIds(358,2))}
    <a href="tel:+999999999999"> <i class="fa fa-phone"></i> 999999999999</a>	  
{else}
    <a href="tel:+1111111111111"> <i class="fa fa-phone"></i> 1111111111111</a>	 
{/if}