Created
October 19, 2022 10:57
-
-
Save sashabeep/91bdcf159d1ad399bccbc4b88ddd738f to your computer and use it in GitHub Desktop.
Вывод произвольных TV параметров с подписями
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 | |
//получает 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; | |
} | |
} | |
} | |
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
<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