Post-Übersicht

Forum » mh_branchenbuch » Suchanfrage mit pageBrowser

Write a post ...

«« 1 »»

Author Message

Hoernerice

Offline Author

Level 1 (57 %)

 

Posts: 5

Ich hab versucht die Fkt. displaySearch so zu ändern das der PageBrowser für die Suche funktioniert. Leider nur mit leidlcihem erfolg. das "limit" funktioniert, aber wenn ich die nächste seit anclick is die seite leer.
hier ma mein gepfusche aus der class.tx_mhbranchenbuch_pi1.php (zeile ~345)^^

Language: Text
  1. /* PAGEBROWSER INIT */

  2.                 $enableFields = $this->cObj->enableFields($this->dbTable1);

  3.                

  4.                 $res_c = $GLOBALS['TYPO3_DB']->exec_SELECTquery(

  5.                   'uid',

  6.                   $this->dbTable1,

  7.                   '`pid` IN(' . intval($pid) . ') ' . $query . ' ' . $enableFields

  8.                 );

  9.                

  10.                 $count = $GLOBALS['TYPO3_DB']->sql_num_rows($res_c);

  11.                

  12.                 if (!isset($this->piVars['page'])) $this->piVars['page'] = 0;

  13.                 $limit = $this->piVars['page'] * $this->resultsPerPage . "," . $this->resultsPerPage;

  14.                

  15.                 $pageBrowser = array(

  16.                   'pid'   => $pid,

  17.                   'limit' => $limit,

  18.                   'page'  => $this->piVars['page'],

  19.                   'table' => $this->dbTable1,

  20.                   'count' => $count,

  21.                 );

  22.                 //michse

  23.       $res = $GLOBALS['TYPO3_DB']->sql(TYPO3_db,"

  24.         SELECT

  25.           f.*,

  26.           k.name AS category

  27.         FROM

  28.           " . $this->dbTable1 . " f

  29.           JOIN " . $this->dbTable2 . " k ON k.uid = f.kategorie

  30.         WHERE

  31.           f.pid IN (" . intval($pid) . ")

  32.           " . $query . "

  33.         ORDER BY

  34.           f.firma ASC

  35.         LIMIT " . $limit . "

  36.       ");



This Post was edited 6 times so far, last change on 27. May 10
Posted: 27.05.10, 21:46

Quote

Martin Hesse

Offline Moderator

Level 10 (63 %)

 

Posts: 203

Hi,

das sieht schonmal garnicht übel aus. Wo weist du den den Pagebrowser dem Content zu? Du musst schauen das du die Werte mit übergibst, d.h das Schlüsselwort, wonach gesucht wird usw.

Gruß,
Martin


Posted: 28.05.10, 19:33

Quote

Hoernerice

Offline Author

Level 1 (57 %)

 

Posts: 5

Das so bischen mein problem. reicht da, das array um 'keyword' => $keyword1 zu erweitern?


Posted: 29.05.10, 15:02

Quote

Hoernerice

Offline Author

Level 1 (57 %)

 

Posts: 5

Ich hab am anfang folgendes versucht:

Language: Text
  1.     if(!isset($this->piVars['keyword1']) || !isset($this->piVars['keyword2']))

  2.     {

  3.             $keyword1             = t3lib_div::_GP('keyword');

  4.             $keyword2             = t3lib_div::_GP('keyword2');

  5.             $this->piVars['keyword1'] = $keyword1;

  6.             $this->piVars['keyword2'] = $keyword2;

  7.     }

  8.     else

  9.     {

  10.         if(isset($this->piVars['keyword1']))

  11.         {

  12.                 $keyword1 = $this->piVars['keyword1'];

  13.         }

  14.         else if(isset($this->piVars['keyword2']))

  15.         {

  16.                 $keyword2 = $this->piVars['keyword2'];

  17.         }

  18.         else

  19.         {

  20.                 $keyword1 = $this->piVars['keyword1'];

  21.                 $keyword2 = $this->piVars['keyword2'];

  22.         }

  23.     }



leider hat das nur das ergebnis, das auf der suchseite die ersten 10treffer angezeigt werden, wenn ich nun weiter klick um auf die nächste seite zu kommen ist diese leider wieder leer und der link hat sich zu /suchergebnis/1.html?tx_mhbranchenbuch_pi1[keyword2]=esslingen geändert

NACHTRAG:
Ich hab festgestellt, das es Funktioniert wenn man 2 suchwörter eingibt. also eines in das Wer/Was feld und eines in das Wo feld. wenn man nur eines der beiden verwendet fkt. es nicht.



This Post was edited 2 times so far, last change on 29. May 10
Posted: 29.05.10, 15:46

Quote

Hoernerice

Offline Author

Level 1 (57 %)

 

Posts: 5

^^ *rotwird*
macht in dem ersten if aus dem || ein && und es tut ^^


Posted: 29.05.10, 18:38

Quote

Hoernerice

Offline Author

Level 1 (57 %)

 

Posts: 5

der vollständigkeitshalber die fertige komplette displaySearch() (noch eine kleinigkeit geändert das au richtig tut wies soll ^^):

Language: Text
  1. function displaySearch($pid) {

  2.     $markerArray          = array();

  3.     $wrappedSubpartArray  = array();

  4.    

  5.     if(!isset($this->piVars['keyword1']) && !isset($this->piVars['keyword2']))

  6.     {

  7.             $keyword1 = t3lib_div::_GP('keyword');

  8.             $keyword2 = t3lib_div::_GP('keyword2');

  9.             $this->piVars['keyword1'] = $keyword1;

  10.             $this->piVars['keyword2'] = $keyword2;

  11.     }

  12.     else

  13.     {

  14.         if(isset($this->piVars['keyword1']) && !isset($this->piVars['keyword2']))

  15.         {

  16.                 $keyword1 = $this->piVars['keyword1'];

  17.                 //$keyword2 = "";

  18.         }

  19.         else if(!isset($this->piVars['keyword1']) && isset($this->piVars['keyword2']))

  20.         {

  21.                 //$keyword1 = "";

  22.                 $keyword2 = $this->piVars['keyword2'];

  23.         }

  24.         else

  25.         {

  26.                 $keyword1 = $this->piVars['keyword1'];

  27.                 $keyword2 = $this->piVars['keyword2'];

  28.         }

  29.     }

  30.    

  31.     $selectBox            = t3lib_div::_GP('tx_mh_branchenbuch_postVar');

  32.    

  33.     $bundesland           = $this->piVars['bid'];

  34.     $landkreis            = $this->piVars['lid'];

  35.     $ort                  = $this->piVars['oid'];

  36.      

  37.     $query                = FALSE; #init

  38.    

  39.     // Some language

  40.     $markerArray['###LANG_SEARCH_WHO###']     = $this->pi_getLL('search_who');

  41.     $markerArray['###LANG_SEARCH_WHERE###']   = $this->pi_getLL('search_where');

  42.     $markerArray['###LANG_SEARCH_SUBMIT###']  = $this->pi_getLL('search_submit');

  43.         // Show number of results

  44.     $markerArray['###MENGE###']  = $this->pi_getLL('search_number_of');

  45.     $template = $this->cObj->getSubpart($this->template,"###SEARCHBOX###");

  46.    

  47.     $minLengthKeyword1 = $this->minLengthKeyword1 ? $this->minLengthKeyword1 : 3;

  48.     $minLengthKeyword2 = $this->minLengthKeyword2 ? $this->minLengthKeyword2 : 3;

  49.    

  50.     if($keyword1 != "" && $keyword1 != "%" && strlen(trim($keyword1)) >= $minLengthKeyword1) {

  51.       $query .= ' AND ';

  52.       $query .= $this->getSearchResultsKeyword1($keyword1);

  53.     }

  54.    

  55.     if($keyword2 != "" && $keyword2 != "%" && strlen(trim($keyword2)) >= $minLengthKeyword2) {

  56.       $query .= $this->getSearchResultsKeyword2($keyword2);

  57.     }

  58.    

  59.     if($query) {

  60. /* PAGEBROWSER INIT */

  61.                 $enableFields = $this->cObj->enableFields($this->dbTable1);

  62.                

  63.                 $res_c = $GLOBALS['TYPO3_DB']->sql(TYPO3_db,"

  64.         SELECT

  65.           f.*,

  66.           k.name AS category

  67.         FROM

  68.           " . $this->dbTable1 . " f

  69.           JOIN " . $this->dbTable2 . " k ON k.uid = f.kategorie

  70.         WHERE

  71.           f.pid IN (" . intval($pid) . ")

  72.           " . $query . "

  73.         ORDER BY

  74.           f.firma ASC

  75.         ");

  76.                

  77.                 $count = $GLOBALS['TYPO3_DB']->sql_num_rows($res_c);

  78.                

  79.                 if (!isset($this->piVars['page'])) $this->piVars['page'] = 0;

  80.                 $limit = $this->piVars['page'] * $this->resultsPerPage . "," . $this->resultsPerPage;

  81.                

  82.                 $pageBrowser = array(

  83.                   'pid'   => $pid,

  84.                   'limit' => $limit,

  85.                   'page'  => $this->piVars['page'],

  86.                   'table' => $this->dbTable1,

  87.                   'count' => $count,

  88.                 );

  89.                 //michse

  90.       $res = $GLOBALS['TYPO3_DB']->sql(TYPO3_db,"

  91.         SELECT

  92.           f.*,

  93.           k.name AS category

  94.         FROM

  95.           " . $this->dbTable1 . " f

  96.           JOIN " . $this->dbTable2 . " k ON k.uid = f.kategorie

  97.         WHERE

  98.           f.pid IN (" . intval($pid) . ")

  99.           " . $query . "

  100.         ORDER BY

  101.           f.firma ASC

  102.         LIMIT " . $limit . "

  103.       ");

  104.      

  105.       if($GLOBALS['TYPO3_DB']->sql_num_rows($res_c)) {

  106.                

  107.                 //$markerArray['###MENGE###'] = 'Anzahl der Einträge: '.$GLOBALS['TYPO3_DB']->sql_num_rows($res);

  108.                 $markerArray['###MENGE###'] = 'Anzahl der Einträge: '.$count;

  109.         $markerArray['###SEARCHRESULT###']  = $this->getItem($res,TRUE,'',$pageBrowser);

  110.                

  111.       }

  112.       else

  113.       {

  114.         $markerArray['###SEARCHRESULT###']  = $this->pi_getLL('search_not_found');

  115.       }

  116.     }

  117.  



btw. kann ich dem "code" kein farbhighlighting verpassen?



This Post was edited 3 times so far, last change on 29. May 10
Posted: 29.05.10, 19:52

Quote


«« 1 »»

Powered by MH-Dev.-Board (c) 2009 MH-Dev. - Webdevelopment.