Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
return array(
'resource' => 'current',
'fields' => 'pagetitle:3,introtext:2',
'wordDelimiter' => ' ',
'returnFields' => 'pagetitle,longtitle,introtext',
'returnTVs' => '',

Expand Down
11 changes: 10 additions & 1 deletion core/components/getrelated/model/getrelated.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ function __construct(modX &$modx,array $config = array()) {
if (isset($a) && count($a) > 0) $this->config['parents'] = $a;
$this->config['exclude'] = explode(',',$this->config['exclude']);

/* Delimiter used to explode each field */
$this->config['wordDelimiter'] = isset($this->config['wordDelimiter']) ? $this->config['wordDelimiter'] : ' ';

$fields = explode(',',$this->config['fields']);
foreach ($fields as $fld) {
$tmp = explode(':',$fld);
Expand Down Expand Up @@ -172,7 +175,13 @@ public function getMatchData() {
/* Fetch resource data */
$resValues = $this->resource->get($this->fields);
$resValues = (is_array($resValues)) ? implode(' ',$resValues) : $resValues;
$resValues = explode(' ',trim($resValues));
if(!empty($this->config['wordDelimiter'])) {
$resValues = explode($this->config['wordDelimiter'],trim($resValues));
}
else {
// Handle case where empty delimiter is passed.
$resValues = array(trim($resValues));
}

/* Combine the data and filter out duplicates, non-alphanum and stop words. */
$values = array_merge($values,$resValues);
Expand Down