Good evening everyone!

I filter the elements on the site with ModX Evo. In my ProjectFilter snippet, I call the Ditto snippet with the necessary parameters for filtering. I see in $ html after processing that placeholders are substituted, but the call to the snippet remains the text "[! Get_multi_image ...]]". Although there should be a picture (in the directory the same template is used, and it is displayed).

I suspect that the problem may be due to the fact that I call Ditto from my snippet. Tell me, how can I solve it?

//////////////// //snippet ProjectFilter //////////////// <?php $pfType = (isset($_POST['pf']['select26'])) ? cleanText($_POST['pf']['select26']) : ''; //Параметры и вызов Ditto из сниппета $params['depth'] = 2; $params['tpl'] = 'project_filter_tpl'; // Простой вызов шаблона... if (!empty($pfType)) $params['filter'] = 'tv_prod_18,'.$pfType.',1'; $html = $modx->runSnippet('Ditto', $params); //вызываем Ditto return $html; function cleanText($text){ $text = htmlentities($text, ENT_QUOTES); $text = strip_tags($text); $text = trim($text); $text = mysql_real_escape_string($text); return $text; } ?> //////////////// //chunk project_filter_tpl //////////////// <a href="[~[+id+]~]" rel="[+id+]"><img src="assets/classes/timthumb/timthumb.php?src=[!get_multi_image? &tvname=`md_gallery` &docid=`[+id+]` &number=`0`!]&w=231&h=144&zc=1" /></a> //////////////// //snippet get_multi_image //////////////// <?php $tvf = $modx->getTemplateVar($tvname, "*", $docid); $fotoArr=json_decode($tvf['value']); return $fotoArr[0][$number]; ?> 

    1 answer 1

    The problem really turned out to be that due to runSnippet, nested snippets do not start and must be started manually. The decision cited below. I took the first 3 lines from the modX kernel (i.e., also how it is done in it), the last was cited somewhere on the forum boards. What does it do and if it is needed - until I looked ...

     //Run Ditto $html = $modx->runSnippet('Ditto', $params); //Manual processing of nested snippets. Because they doesn't work after runSnippet $html = str_replace('[!', '[[', $html); //Взято из ядра $html = str_replace('!]', ']]', $html); //Взято из ядра $html = $modx->parseDocumentSource($html); //Взято из ядра $html = $modx->evalSnippets($html); //Взято из советов на форуме. Насчёт правильности не уверен, надо посмотреть в ядре что она делает return $html;