[TYPO3] problem with wfqbe (ext) and preProcessQueryStructure (hook)

Mauro Lorenzutti mauro.lorenzutti at webformat.com
Mon Jan 28 09:07:37 CET 2008


Hi Martin,


[...]

> The query structure looks like this:
> 
> SELECT * FROM dbliterature WHERE ( dbliterature.author LIKE 
> '%###WFQBE_AUTHOR###%' OR dbliterature.institution LIKE 
> '%###WFQBE_AUTHOR###%' ) AND ( dbliterature.title LIKE 
> '%###WFQBE_TITLE###%' OR dbliterature.journal_title LIKE 
> '%###WFQBE_TITLE###%' ) AND ( dbliterature.descriptor LIKE 
> '%###WFQBE_DESCRIPTOR###%' OR dbliterature.abstract LIKE 
> '%###WFQBE_DESCRIPTOR###%' )
> 
> I then created a search form page with the wfqbe-extension which 
> provides several input areas each connected to the according markers for 
> author, title, descriptors, etc. Leaving one of these input areas blank 
> (e.g. searching by an author's name only, not giving a search input for 
> "title") the extension should disregard the unused markers and generate 
> a MYSQL search query based on used inputs only.
> 
> Example:
> 
> author: Smith
> title: nations
> descriptor: BLANK
> 
> I used the hook mentioned in the extension's documentation 
> (preProcessQueryStructure) and configured it as described in a list post 
> (http://www.typo3board.com/ftopic12181.html), as follows:
> 
> class tx_wfqbe_preprocessquery    {
>     function tx_wfqbe_preprocessquery()    {
>     }            function process_query_structure($wfqbe, $piVars, 
> $query_uid,
> &$callingObj)    {
>         $remove = array();
>         // Query to be processed
>         if ($query_uid==13)    {                    $markers = array(
>                            "AUTHOR", "TITLE", "DESCRIPTOR"
>                             );
>             foreach ($markers as $marcatore)    {
>                 if ($piVars[$marcatore]=='' ||
> (is_array($piVars[$marcatore]) && $piVars[$marcatore][0]==''))    {
>                     foreach ($wfqbe[0]['insert'] as $key => $value)    {
>                         if (strpos($value, 'WFQBE_'.$marcatore)>0)    {
>                             $remove[] = $key;
>                             unset($wfqbe[0]['insert'][$key]);
>                         }
>                     }
>                 }
>             }
>         }
>         return $remove;
>     }
> }

[...]

the problem is that you used the same marker more than one time. This is 
not a problem but you need to modify the hook code to remove all the 
unused markers.

try to modify the following line of code:

if (strpos($value, 'WFQBE_'.$marcatore)>0)    {

with this new code:

while (strpos($value, 'WFQBE_'.$marcatore)>0)    {

I didn't test it but it should remove all the unused markers.


Best regards,
-- 
  Mauro Lorenzutti

e-mail:  mauro.lorenzutti at webformat.com
---------------------------------------------------------
WEBFORMAT srl | Corte Europa, 12 | I-33097 SPILIMBERGO PN
      Tel +39-0427-926.389  --  Fax +39-0427-927.653
        info at webformat.com  --  http://www.webformat.com
---------------------------------------------------------


More information about the TYPO3-english mailing list