Created
October 9, 2020 07:58
-
-
Save sashabeep/385eb5b9e8c48ef4538fe7706a556de3 to your computer and use it in GitHub Desktop.
Find in set snippet for Evolution CMS
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 | |
$id = $modx->documentObject['id']; | |
$res = $modx->db->select("contentid", $modx->getFullTableName('site_tmplvar_contentvalues'), "FIND_IN_SET('".$id."',value) AND tmplvarid=9"); | |
$arr = $modx->db->makeArray($res); | |
$final = Array(); | |
foreach($arr as $k=>$v){ | |
$final[]=($v['contentid']); | |
} | |
return(implode(",",$final)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
usage:
Используется для построения списка id документов, в tv параметре которого указан текущий документ. Например, на странице тренировки есть поле TV с id=9, в него через запятую вписаны id документов с тренерами с помощью Selector.
А на странице тренеров запускается сниппет для поиска всех документов, в которых указан тренер. Для упрощения перекрестных связей. В противном случае пришлось бы и в тренировках указывать тренеров, и в тренерах - тренировки