Last active
February 21, 2020 12:28
-
-
Save ig0r74/2f86fb8002f287f7990169f6188b23aa to your computer and use it in GitHub Desktop.
MODX Revolution, pdoResources группировка результатов leftJoin GROUP_CONCAT
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{* К одному региону может принадлежать несколько магазинов *} | |
{set $fdkRegions = '!pdoResources' | snippet : [ | |
'class' => 'fdkRegion', | |
'select' => '{ | |
"fdkRegion":"*", | |
"Shop":"GROUP_CONCAT(Shop.region_id) AS region_id, Shop.main_contact_phone as main_contact_phone" | |
}', | |
'groupby' => 'code', | |
'leftJoin' => '{ | |
"fdkShop": { | |
"class":"fdkShop", | |
"alias":"Shop", | |
"on": "Shop.region_id = fdkRegion.code" | |
} | |
}', | |
'limit' => 0, | |
'sortby' => 'id', | |
'where' => [ | |
'active' => true, | |
'Shop.active' => true, | |
], | |
'return' => 'json', | |
] | fromJSON} | |
{foreach $fdkRegions as $region} | |
<a href="#" data-id="{$region.code}"> | |
<span class="ncontactslink1">{$region.name}</span> | |
<span class="ncontactslink2">{$region.phone ?: $region.main_contact_phone}</span> | |
</a> | |
{/foreach} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{'!Localizator' | snippet : [ | |
'snippet' => 'mFilter2', | |
'parents' => $parent, | |
'templates' => '4', | |
'tpl' => 'good.category', | |
'includeThumbs' => 'big', | |
'limit' => '10', | |
'class' => 'msProduct', | |
'element' => 'msProducts', | |
'sortby' => $sort, | |
'sortdir' => 'DESC', | |
'ajaxMode'=>'scroll', | |
'includeTVs' => 'video,video_show', | |
'filters' => 'ms|hexcolor:default,msoption|size:default,msoption|material:default,ms|price:number', | |
'tplOuter' => 'in.mFilter2.outer', | |
'tplFilter.outer.default' => 'in.mFilter2.filter.outer', | |
'tplFilter.row.default' => 'in.mFilter2.filter.checkbox', | |
'tplFilter.outer.ms|price' => 'in.mFilter2.filter.slider', | |
'tplFilter.row.ms|price' => 'in.mFilter2.filter.number', | |
'tplFilter.row.ms|hexcolor' => 'in.mFilter2.filter.hexcolor', | |
'leftJoin' => [ | |
"big_2" => [ | |
"class" => "msProductFile", | |
"alias" => "big_2", | |
"on" => "big_2.product_id = msProduct.id AND big_2.rank = 1 AND big_2.path LIKE '%/big/%'" | |
], | |
"msprRemains" => [ | |
"class" => "msprRemains", | |
"alias" => "Remain", | |
"on" => "Remain.product_id = msProduct.id" | |
] | |
], | |
'select' => [ | |
"big_2" => "big_2.url as big_2", | |
"Remain" => "GROUP_CONCAT(Remain.options, \"::\", Remain.remains SEPARATOR \"&&\") AS remain_options" | |
], | |
'where' => $where | |
]} | |
---------- | |
{set $sizes = $remain_options | split : '&&'} | |
<div class="size-row"> | |
{foreach $sizes as $size} | |
{set $size = $size | split : "::"} | |
{set $opt = $size[0] | fromJSON} | |
{if $opt.shop == 'Интернет-магазин' && $size[1] > 0} | |
<label class="size-item size-item-cat"> | |
<input type="radio" name="options[size]" value="{$opt.size}">{$opt.size} | |
</label> | |
{/if} | |
{/foreach} | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment