public function onTagSearch(&$query, &$where, $tag = null) { if (!$this->params->get("tag_search", 0)) { return false; } if ($tag !== "") { $tag = JUDirectoryFrontHelper::UrlDecode($tag); $address_id = (int) $tag; if ($address_id) { $db = JFactory::getDbo(); $_query = $db->getQuery(true); $_query->select('n.id')->from('#__judirectory_addresses AS n, #__judirectory_addresses AS p')->where('n.lft BETWEEN p.lft AND p.rgt')->where('p.id = ' . $address_id)->order('n.lft'); $db->setQuery($_query); $address_ids = $db->loadColumn(); $query->join('LEFT', '#__judirectory_locations AS location ON location.listing_id = listing.id'); $where[] = 'location.address_id IN (' . implode(', ', $address_ids) . ')'; $query->group('listing.id'); } } }
public function onSimpleSearch(&$query, &$where, $search) { if ($search !== "") { $search = JUDirectoryFrontHelper::UrlDecode($search); $db = JFactory::getDbo(); $_query = array(); $query->join('LEFT', '#__judirectory_locations AS location ON location.listing_id = listing.id'); $_query[] = $db->quoteName('location.address') . " LIKE " . $db->quote("%" . $search . "%"); $_query[] = $db->quoteName('location.description') . " LIKE " . $db->quote("%" . $search . "%"); $query->join('LEFT', '#__judirectory_addresses AS address ON address.id = location.address_id'); $where[] = '(' . implode($_query, ' OR ') . ')'; } }
public function onTagSearch(&$query, &$where, $tag = null) { if (!$this->params->get("tag_search", 0)) { return false; } if (is_null($tag)) { $app = JFactory::getApplication(); $tag = $app->input->get("tag", "", "string"); } if (!$this->isCore()) { $query->join('', '#__judirectory_fields_values AS field_values_' . $this->id . ' ON (listing.id = field_values_' . $this->id . '.listing_id AND field_values_' . $this->id . '.field_id = ' . $this->id . ')'); } if ($tag !== "") { $tag = JUDirectoryFrontHelper::UrlDecode($tag); $db = JFactory::getDbo(); $_where = "(( " . $this->fieldvalue_column . " = " . $db->quote($tag) . " OR " . $this->fieldvalue_column . " LIKE '" . $db->escape($tag, true) . "|%'" . " OR " . $this->fieldvalue_column . " LIKE '%|" . $db->escape($tag, true) . "|%'" . " OR " . $this->fieldvalue_column . " LIKE '%|" . $db->escape($tag, true) . "' )"; $_where .= " OR ( " . $this->fieldvalue_column . " LIKE '" . $db->escape($tag, true) . ",%'" . " OR " . $this->fieldvalue_column . " LIKE '%," . $db->escape($tag, true) . ",%'" . " OR " . $this->fieldvalue_column . " LIKE '%," . $db->escape($tag, true) . "' ))"; $where[] = $_where; } }