Skip to content

Commit

Permalink
Fix issue processwire/processwire-issues#344 using page name with not…
Browse files Browse the repository at this point in the history
…-equals operator in FieldtypePage selector
  • Loading branch information
ryancramerdesign committed Aug 22, 2017
1 parent a135572 commit f678f9f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions modules/Fieldtype/FieldtypePage.module
Expand Up @@ -743,14 +743,21 @@ class FieldtypePage extends FieldtypeMulti implements Module, ConfigurableModule

return parent::getMatchQuery($query, $table, $subfield, $operator, $value);

} else if(in_array($subfield, $names)) {
} else if(in_array($subfield, $names) || ($subfield == 'name' && $operator == '!=')) {

if(!$database->isOperator($operator)) {
throw new WireException("Operator '$operator' is not implemented in {$this->className}");
}

if(in_array($subfield, array('id', 'path', 'url'))) $subfield = 'data';

if($subfield == 'name') {
$value = $this->wire('sanitizer')->pageName($value);
$value = implode(',', $this->pages->findIDs("name=$value, include=all"));
if(empty($value)) $value = "0";
$idstr = true;
}

if(in_array($subfield, array('id', 'path', 'url', 'name'))) $subfield = 'data';

// if a page path rather than page ID was provided, then we translate the path to an ID for API syntax convenience
if($idstr || !ctype_digit("$value")) {
if(is_null($idstr) && $subfield == 'data' && strpos($value, ',') !== false) {
Expand Down

0 comments on commit f678f9f

Please sign in to comment.