Accueil > Divers > Infographiste > CMS > Typo3 > Extension Search In Tables

Extension Search In Tables

jeudi 17 juillet 2008, par Philippe Donnart

Pour rechercher dans une ou plusieurs tables à l’aide d’un formulaire de recherche sous Typo3.

What does it do ?
 The extension allows your visitors to search in previously defined tables. This extension is intended to overcome the indexed search limitation to search in cached pages. Although many extensions have their own search tool for their type of records, this extension allows the developer to configure a search in many tables at the same time, and how the results should be shown to the visitors, both on the list view and the single item view.
 The extension provides a plugin that can output the search form, the results list, and the single view for a selected item. It should also be configured via typoscript to send the visitor to a page where the table single view could be already configured, eg : the page where you already have the single news pagecontent element configured.
 The search algorithm is very simple, and it performs a simple non-boolean search. It uses tslib_pibase standard search capabilities.
 It is a complex extension, as it requires very good knowledge of typoscript.

Je souhaitais pouvoir rechercher dans un champ particulier de la table tt_content (ici le header = entête de la page) au travers d’un formulaire de recherche, et afficher les résultats sous forme de liste.
Pour faire plus sympa, j’ai rajouté le début du texte coupé à 200 caractères.
tt_content.pidList = 13 page à partir de laquelle j’effectue la recherche
Voici le code

### SEARCH IN TABLES ###

plugin.tx_fesearchintable_pi1 {

   searchTables {
      tt_news >
      tt_content = 1
      tt_content.name = Fiche Entreprise
      tt_content.fields = header,bodytext
      tt_content.pidList = 13
      tt_content.recursive = 1
      tt_content.listHeader = COA
      tt_content.listHeader {
       10 = TEXT
       10.value = Fiche Entreprise
       10.wrap = <h3 style="background-color:#FFCC66; color:white; padding: 4px">|</h3>
      }
      tt_content.listItem = COA
      tt_content.listItem {
    stdWrap.wrap = <li>|</li>
       10 = TEXT
       10.field = header
       10.wrap = <strong>Fiche Entreprise: </strong><strong style='color:#006699;'>|</strong><br>
       20 = TEXT
       20.field = bodytext
       20.crop = 200|...&nbsp;
       30 = TEXT
       30.value = {$more}<font size=1>></font>
       30.typolink.parameter.data = TSFE:id
       30.typolink.wrap = <strong>|</strong>
       30.typolink.ATagBeforeWrap = 1
       30.typolink.additionalParams.dataWrap = &tx_fesearchintable_pi1[sTable]=tt_content&&tx_fesearchintable_pi1[sUID]={field:uid}
       
      }
      tt_content.listStdWrap.wrap = <ol style="margin-top:-10px">|</ol>
      tt_content.singleView = COA
      tt_content.singleView {
   10 = TEXT
   10.field = header
   10.wrap = <h3>|</h3><br>
   20 = TEXT
   20.field = bodytext
   20.wrap = |<br><br>
      }
  }
}

Ensuite j’ai placé le plugin sur une page (constante => le pid de la page de résultat, et both) et sur la page de résultats.

Pour avoir le moteur de recherche en-dessous sur la page résultats, il faut modifier both
par results,form
plugin.tx_fesearchintable_pi1.CMD = results,form

Pour modifier les paramètres de langues dans le typoscript
Exemple pour le FR

Dans les constantes écrire

[globalVar = GP:L = 0]
more = plus d'informations
[globalVar]

et dans le setup

30.value = {$more}<font size=1>></font>

Voir en ligne : Extension Search In Tables