Hello, I had some issues when I configured latest version of Ditto with the suggested changes on page 4. I kept getting these errors:
« MODx Parse Error »
MODx encountered the following error while attempting to parse the requested resource:
« PHP Parse Error »
PHP error debug
Error: array_walk(): Unable to call ditto::applyHsc() - function does not exist
Error type/ Nr.: Warning - 2
File: ****/cms/assets/snippets/ditto/classes/ditto.class.inc.php
Line: 1037
Line 1037 source: $keyvalue = (is_array($value)) ? array_walk($value,"ditto::applyHsc") : htmlspecialchars($value, ENT_QUOTES);
So I commented this line:
// $keyvalue = (is_array($value)) ? array_walk($value,"ditto::applyHsc") : htmlspecialchars($value, ENT_QUOTES);
and it all worked beautifully. Until I noticed that my pagination stopped working.
Then I uncommented the line and pagination works again across the site, but the tvexplorer snippet doesn’t work. I keep getting:
« MODx Parse Error »
MODx encountered the following error while attempting to parse the requested resource:
« PHP Parse Error »
PHP error debug
Error: array_walk(): Unable to call ditto::applyHsc() - function does not exist
Error type/ Nr.: Warning - 2
File: ****/cms/assets/snippets/ditto/classes/ditto.class.inc.php
Line: 1037
Line 1037 source: $keyvalue = (is_array($value)) ? array_walk($value,"ditto::applyHsc") : htmlspecialchars($value, ENT_QUOTES);
Any ideas?
function applyHsc($var){
$var = htmlspecialchars($var, ENT_QUOTES);
}
function buildURL($args,$id=false,$dittoIdentifier=false) {
global $modx, $dittoID;
$dittoID = ($dittoIdentifier !== false) ? $dittoIdentifier : $dittoID;
$query = array();
foreach ($_GET as $param=>$value) {
if ($param != 'id' && $param != 'q') {
// $query[htmlspecialchars($param, ENT_QUOTES)] = htmlspecialchars($value, ENT_QUOTES);
$keyparam =htmlspecialchars($param, ENT_QUOTES);
$keyvalue = (is_array($value)) ? array_walk($value,"ditto::applyHsc") : htmlspecialchars($value, ENT_QUOTES);
$query[$keyparam] = $keyvalue;
}
}
if (!is_array($args)) {
$args = explode("&",$args);
foreach ($args as $arg) {
$arg = explode("=",$arg);
$query[$dittoID.$arg[0]] = urlencode(trim($arg[1]));
}
} else {
foreach ($args as $name=>$value) {
$query[$dittoID.$name] = urlencode(trim($value));
}
}
$queryString = "";
foreach ($query as $param=>$value) {
$queryString .= '&'.$param.'='.(is_array($value) ? implode(",",$value) : $value);
}
$cID = ($id !== false) ? $id : $modx->documentObject['id'];
//$url = $modx->makeURL(trim($cID), '', $queryString);
$url = (isset($modx->documentObject['id'])) ? $modx->makeURL(trim($cID), '', $queryString) : 'index.php?id='.$GLOBALS['modID'].$queryString;
return ($modx->config['xhtml_urls']) ? $url : str_replace("&","&",$url);
}
Maybe the applyHsc function goes somewhere else?
I appreciate the help.
Jose R. Lopez