Skip to content

Instantly share code, notes, and snippets.

@sashabeep
Created October 19, 2022 10:57
Show Gist options
  • Save sashabeep/91bdcf159d1ad399bccbc4b88ddd738f to your computer and use it in GitHub Desktop.
Save sashabeep/91bdcf159d1ad399bccbc4b88ddd738f to your computer and use it in GitHub Desktop.
Вывод произвольных TV параметров с подписями
<php
//получает TV текущего документа с сортировкой по категории
$val = $modx->getTemplateVars('*', '*', $documentObject['id'],1,'category');
$tvcategories = Array(10); //ID категории TV параметров товара
$tvexclude = Array(16,17,43,45); //ID TV которые нужно исключить
//тут всё и так понятно
$productOptions = Array();
if(is_array($val) && !empty($val)){
foreach ($val as $key=>$val){
if( in_array($val['category'],$tvcategories) && !(in_array($val['id'],$tvexclude)) && $val['value']!=''){
$productOptions[]=$val;
}
}
}
<h2 class="h3">Технические характеристики {{ $documentObject['pagetitle'] }}</h2>
@if(!empty($productOptions))
<ul>
@foreach ($productOptions as $item)
<li><b>{{ $item['caption'] }}:</b> {{ str_replace("||",", ",$item['value']) }}</li>
@endforeach
</ul>
@endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment