Skip to content

Instantly share code, notes, and snippets.

@Sentinel-7
Last active May 15, 2021 16:15
Show Gist options
  • Save Sentinel-7/6166f211517bbd2f8ae6724efb07672a to your computer and use it in GitHub Desktop.
Save Sentinel-7/6166f211517bbd2f8ae6724efb07672a to your computer and use it in GitHub Desktop.
tagger выводим товары привязанные к alias тегам
{set $par = $_modx->resource.parent | url}
{set $getTag = $_modx->resource.id | url | replace : $par : ''}
{set $parents = $_modx->resource.parent}
{*Находим шаблон родителя*}
{set $parentTemplate = $parents | resource: 'template'}
{*Если это тег, значит поднимаемся выше для получения родителя*}
{if $parentTemplate == 27}
{set $parents = $parents | resource: 'parent'}
{/if}
[[!mFilter2?
&limit=`18`
&ajax=`0`
&parents=`{$parents}`
&element=`msProducts`
&tpls=`tpl.product-new-catalog`
&tplOuter=`tpl.catalog-new-filter.outer`
&tplPageWrapper=`tplPageWrapper`
&tplPageNextEmpty=``
&tplPagePrevEmpty=``
&paginator=`pdoPage`
&includeThumbs=`360x270`
&includeTVs=`new_stock`
&sort=`tv|new_stock:ASC`
&pageLinkScheme=`[[+pageVarKey]]/[[+page]]/`
&pageVarKey=`page`
&page=`1`
&leftJoin=`{
"TaggerTagResource": {
"class": "TaggerTagResource",
"on": "TaggerTagResource.resource = msProduct.id"
},
"TaggerTag": {
"class": "TaggerTag",
"on": "TaggerTagResource.tag = TaggerTag.id"
}
}`
&where=`{ "TaggerTag.alias":"{$getTag}" }`
&filters=`
ms|vendor:vendors,
ms|power,
tv|product_volume,
tv|product_interface,
tv|product_inch,
tv|product_speed,
tv|product_kit,
tv|product_memory_frequency,
tv|product_memory_speed,
tv|product_memory_standard,
tv|product_memory_type`
&tplFilter.outer.default=`tpl.filter.row-catalog-new-power`
&tplFilter.row.default=`tpl.filter.checkbox-catalog-new-power`
]]
Fenom
{'!mFilter2' | snippet : [
'limit' => 18,
'parents' => $parents,
'element' => 'msProducts',
'tpls' => 'tpl.product-new-catalog',
'tplOuter' => 'tpl.catalog-new-filter.outer',
'tplPageWrapper' => 'tplPageWrapper',
'tplWrapper' => '@INLINE <div class="col-md-12 mt-5 mb-5"><h2>Подходящих товаров: {"page.total" | placeholder}</h2></div>{$output}',
'tplPageNextEmpty' => '',
'tplPagePrevEmpty' => '',
'includeThumbs' => '360x270',
'includeTVs' => 'new_stock',
'sort' => 'tv|new_stock:ASC',
'pageLinkScheme' => '[[+pageVarKey]]/[[+page]]/',
'pageVarKey' => 'page',
'page' => 1,
'leftJoin' => '{
"TaggerTagResource": {
"class": "TaggerTagResource",
"on": "TaggerTagResource.resource = msProduct.id"
},
"TaggerTag": {
"class": "TaggerTag",
"on": "TaggerTagResource.tag = TaggerTag.id"
}
}',
'where' => '{ "TaggerTag.alias" : "'~$getTag~'" }',
'filters' => 'ms|vendor:vendors,
ms|power,
tv|product_volume,
tv|product_interface,
tv|product_inch,
tv|product_speed,
tv|product_kit,
tv|product_memory_frequency,
tv|product_memory_speed,
tv|product_memory_standard,
tv|product_memory_type',
'tplFilter.outer.default' => 'tpl.filter.row-catalog-new',
'tplFilter.row.default' => 'tpl.filter.checkbox-catalog-new'
]}
<div id="pdopage">
<div class="row rows">
{'!pdoPage' | snippet : [
'cacheTime' => 86400,
'parents' => 2,
'limit' => 18,
'ajax' => 1,
'ajaxMode' => 'default',
'includeThumbs' => '360x270',
'loadModels' => 'tagger',
'class' => 'TaggerTagResource',
'sortby' => 'TaggerTagResource.resource',
'sortdir' => 'ASC',
'leftJoin' => '{
"NameTag": {
"class": "TaggerTag",
"on": "TaggerTagResource.tag = NameTag.id"
},
"Posts": {
"class": "msProduct",
"on": "TaggerTagResource.resource = Posts.id"
},
"Data": {
"class": "msProductData",
"on": "TaggerTagResource.resource = Data.id"
}
}',
'select' => '{
"TaggerTagResource": "*",
"NameTag": "NameTag.tag, NameTag.alias",
"Posts": "Posts.id, Posts.pagetitle, Data.price, Data.thumb, Data.image"
}',
'where' => '{"NameTag.alias" : "'~$getTag~'"}',
'tpl' => 'tpl.product-new-catalog',
'tplWrapper' => '@INLINE <div class="col-md-12 mt-5 mb-5"><h2>Подходящих товаров: {"page.total" | placeholder}</h2></div>{$output}',
'tplPageWrapper' => '@INLINE <div class="toolbar clearfix"><div class="pagination"><ul>{$prev}{$pages}{$next}</ul></div></div>',
'tplPagePrevEmpty' => '',
'tplPageNextEmpty' => '',
'showLog' => 0
]}
</div>
{'page.nav' | placeholder}
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment