[TYPO3-english] Can anyone help me to check this search function?

Markus Klein klein.t3 at mfc-linz.at
Sat May 19 09:39:32 CEST 2012


Hello, whoever you are...

Sorry to be so direct now, but this is a list for TYPO3 specific questions and problems.
You are asking for general "how to program XYZ" help.

Furthermore I'm not expecting too much if I say it would be a minimum to at least write a Hello at the beginning and your name at the end of an email.

Regards
Markus

> -----Original Message-----
> From: typo3-english-bounces at lists.typo3.org [mailto:typo3-english-bounces at lists.typo3.org] On Behalf Of typo3 study
> Sent: Saturday, May 19, 2012 5:33 AM
> To: TYPO3 English
> Subject: [TYPO3-english] Can anyone help me to check this search function?
> 
> 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.



More information about the TYPO3-english mailing list