documentIdentifier; $tpl = isset($tpl) ? $tpl : null; if($tpl) { $chunk = $modx->getChunk($tpl); if($chunk) { $doclist = explode(",", $doc); foreach($doclist as $doc) { $template = $chunk; // code borrowed from PHx if ( preg_match_all('~\[(\+|\*|\()([^:\+\[\]]+)([^\[\]]*?)(\1|\))\]~s',$template, $matches)) { //$matches[0] // Complete string that's need to be replaced //$matches[1] // Type //$matches[2] // The placeholder(s) //$matches[3] // The modifiers //$matches[4] // Type (end character) $count = count($matches[0]); $var_search = array(); $var_replace = array(); for($i=0; $i<$count; $i++) { $replace = NULL; $match = $matches[0][$i]; $type = $matches[1][$i]; $type_end = $matches[4][$i]; $input = $matches[2][$i]; $modifiers = $matches[3][$i]; switch($type) { // Document / Template Variable eXtended case "*": $ddTemplateVars[] = $input; break; // MODx Placeholder eXtended case "+": $ddPlaceholders[] = $input; break; // MODx Placeholder eXtended default: break; } } // end for loop } // end preg_match_all if(count(array_unique($ddPlaceholders)) > 0) $ddPlaceholderData = $modx->getDocument($doc,implode(array_unique($ddPlaceholders),',')); if(count(array_unique($ddTemplateVars)) > 0) $ddTemplateVarData = $modx->getTemplateVarOutput(array_unique($ddTemplateVars),$doc); if(is_array($ddPlaceholderData)) ddPHParser($template, $ddPlaceholderData); if(is_array($ddTemplateVarData)) ddTVParser($template, $ddTemplateVarData); $output .= $template; /* $output .= "\n"; */ } // end foreach return $output; } // end if chunk } // end if tpl //------------------------------------------------------- // functions only below function ddPHParser(&$template, $fields) { foreach($fields as $name=>$value) { $names[] = '[+'.$name.'+]'; $values[] = $value; } $template = str_replace($names, $values, $template); } function ddTVParser(&$template, $fields) { foreach($fields as $name=>$value) { $names[] = '[*'.$name.'*]'; $values[] = $value; } $template = str_replace($names, $values, $template); } ?>