Created
May 14, 2020 23:32
-
-
Save andronex/b8441287c162af69bb48041164cb453a to your computer and use it in GitHub Desktop.
Все цены из доп. TV в формате TVTable на одной странице
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
<?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; |
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 $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