Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Все цены из доп. TV в формате TVTable на одной странице
<?php
/*
* используется компонент TVTable
*/
$criteria = array();
$criteria['modTemplateVarResource.tmplvarid'] = 18;
$criteria['modTemplateVarResource.value:!='] = '';
$criteria['Resource.template:IN'] = array(9,10);
$criteria = $modx->newQuery('modTemplateVarResource', $criteria);
$tvrs = $modx->getCollectionGraph('modTemplateVarResource','{"Resource":{}}', $criteria);
$out = array();
foreach($tvrs as $tv){
//print_r(json_decode($tv->value, true));
$res = $tv->getOne('Resource');
if($res->get('parent') == 18){
$out[$res->get('pagetitle')][$res->get('menutitle')?:$res->get('pagetitle')] = $modx->runSnippet('TVTable', array(
'wrapperTpl' => '@INLINE <div class="cost__table-block"><table cellspacing="0" cellpadding="0">{$table}</table></div>',
'input' => $tv->get('value')
));
}
else{
$out[$modx->getObject('modResource', $res->get('parent'))->pagetitle][$res->get('menutitle')?:$res->get('pagetitle')] = $modx->runSnippet('TVTable', array(
'wrapperTpl' => '@INLINE <div class="cost__table-block"><table cellspacing="0" cellpadding="0">{$table}</table></div>',
'input' => $tv->get('value')
));
}
}
return $out;
{set $prices = $_modx->runSnippet('@FILE snippets/getprices.php')}
{foreach $prices as $title => $price}
<div class="price-table">
<h2 class="material-title">{$title}</h2>
{set $show_more = false}
{foreach $price as $subtitle => $table}
<div class="price-table__block"{if $table@index > 1} {set $show_more = true}style="display: none;"{/if}>
{if $subtitle != $title}<h3 class="table-title">{$subtitle}</h3>{/if}
{$table}
</div>
{/foreach}
{if $show_more}
<div class="btn-row">
<a href="javascript:void(0);" class="show-more">Показать стоимость резки других материалов <i class="fal fa-chevron-down"></i></a>
</div>
{/if}
</div>
{/foreach}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.