Page 1 of 1

how could I change this search function?

Posted: Fri May 18, 2012 10:58 pm
by tomliuwhite
function search() {
$template = $this->cObj->getSubpart($this->template, '###TEMPLATE_SEARCH###');

$markerArray['###ACTION###'] = $markerArray['###ACTION###'] = $this->pi_getPageLink($GLOBALS['TSFE']->id);
$markerArray['###SEARCH_TITLE###'] = $this->pi_getLL('text_search_title');
$markerArray['###SEARCH_KEYWORD###'] = '<input class="keyword" type="text" name="'.$this->prefixId.'[keyword]"'.($this->piVars['keyword'] ? ' value="'.stripslashes($this->piVars['keyword']).'"' : '').' />';
$markerArray['###SEARCH###'] = $this->pi_getLL('text_search_submit');

$content = $this->cObj->substituteMarkerArray($template, $markerArray);

if ($this->piVars['keyword']) {
$keywords = t3lib_div::trimExplode(' ', $this->piVars['keyword'], true);

$likeClause = '';
if (sizeof($keywords)) {
foreach ($keywords as $index => $word) {
if ($index > 0) {
$likeClause .= ' OR jc.contents LIKE \'%' .$word. '%\'';
} else {
$likeClause .= 'jc.contents LIKE \'%' .$word. '%\'';
}
}

if ($likeClause) $likeClause = '('.$likeClause.')';
}

$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'fe.uid, fe.email, fe.city, fe.tx_jcregister_first_name, fe.tx_jcregister_last_name',
'tx_jcresume_text jc LEFT JOIN fe_users fe ON fe.uid = jc.cruser_id',
$likeClause.' AND jc.active = 1'
);
...
}

Above function works like this:
If I search A B, it will find the resume with A or B word in that.
such as:1. A is good. 2. B is good. 3. A B is good

Now I want to make it function like this:
I. If I search for A+B and it should find every resume with the words A B together,
such as: 1. how are you A B?, 2. A B is coming. 3. A B is good.
II. If I search A B, it will find the resume with both of those 2 words in that, but they do not need be together.
such as: 1.A and B are coming. 2. A will go to B's house. 3. A B are good.

So if I want to see this function, how could I change the above code?

Thanks.