Ergebnis 1 bis 9 von 9

Thema: Core Modul Auflistung > Hinweistext wenn kein Suchergebnis

  1. #1
    Contao-Fan Avatar von mandrake
    Registriert seit
    19.06.2009.
    Ort
    Düsseldorf
    Beiträge
    461

    Standard Core Modul Auflistung > Hinweistext wenn kein Suchergebnis

    Ich suche eine Möglichkeit, um einen Hinweistext anzeigen zu lassen, wenn die Suche im Modul Auflistung kein Ergebnis liefert. Hat jemand eine Idee?

    Nachfolgend das Original Template "list_default":

    Code:
    <div class="<?= $this->class ?> ce_table listing block"<?= $this->cssID ?><?php if ($this->style): ?> style="<?= $this->style ?>"<?php endif; ?>>
    
    
      <?php if ($this->headline): ?>
        <<?= $this->hl ?>><?= $this->headline ?></<?= $this->hl ?>>
      <?php endif; ?>
    
    
      <?php if ($this->searchable): ?>
        <div class="list_search">
          <form<?php if ($this->action): ?> action="<?= $this->action ?>"<?php endif; ?> method="get">
            <div class="formbody">
              <input type="hidden" name="order_by" value="<?= $this->order_by ?>">
              <input type="hidden" name="sort" value="<?= $this->sort ?>">
              <input type="hidden" name="per_page" value="<?= $this->per_page ?>">
              <label for="ctrl_search" class="invisible"><?= $this->fields_label ?></label>
              <select name="search" id="ctrl_search" class="select">
                <?= $this->search_fields ?>
              </select>
              <label for="ctrl_for" class="invisible"><?= $this->keywords_label ?></label>
              <input type="text" name="for" id="ctrl_for" class="text" value="<?= $this->for ?>">
              <input type="submit" class="submit" value="<?= $this->search_label ?>">
            </div>
          </form>
        </div>
      <?php endif; ?>
    
    
      <?php if ($this->per_page): ?>
        <div class="list_per_page">
          <form<?php if ($this->action): ?> action="<?= $this->action ?>"<?php endif; ?> method="get">
            <div class="formbody">
              <input type="hidden" name="order_by" value="<?= $this->order_by ?>">
              <input type="hidden" name="sort" value="<?= $this->sort ?>">
              <input type="hidden" name="search" value="<?= $this->search ?>">
              <input type="hidden" name="for" value="<?= $this->for ?>">
              <label for="ctrl_per_page" class="invisible"><?= $this->per_page_label ?></label>
              <select name="per_page" id="ctrl_per_page" class="select">
                <option value="10"<?php if ($this->per_page == 10): ?> selected="selected"<?php endif; ?>>10</option>
                <option value="20"<?php if ($this->per_page == 20): ?> selected="selected"<?php endif; ?>>20</option>
                <option value="30"<?php if ($this->per_page == 30): ?> selected="selected"<?php endif; ?>>30</option>
                <option value="50"<?php if ($this->per_page == 50): ?> selected="selected"<?php endif; ?>>50</option>
                <option value="100"<?php if ($this->per_page == 100): ?> selected="selected"<?php endif; ?>>100</option>
                <option value="250"<?php if ($this->per_page == 250): ?> selected="selected"<?php endif; ?>>250</option>
                <option value="500"<?php if ($this->per_page == 500): ?> selected="selected"<?php endif; ?>>500</option>
              </select>
              <input type="submit" class="submit" value="<?= $this->per_page_label ?>">
            </div>
          </form>
        </div>
      <?php endif; ?>
    
    
      <table class="all_records">
      <thead>
        <tr>
          <?php foreach ($this->thead as $col): ?>
            <th class="head<?= $col['class'] ?>"><a href="<?= $col['href'] ?>" title="<?= $col['title'] ?>"><?= $col['link'] ?></a></th>
          <?php endforeach; ?>
          <?php if ($this->details): ?>
            <th class="head col_last">&nbsp;</th>
          <?php endif; ?>
        </tr>
      </thead>
      <tbody>
        <?php foreach ($this->tbody as $class=>$row): ?>
          <tr class="<?= $class ?>">
            <?php foreach ($row as $col): ?>
              <td class="body <?= $col['class'] ?>"><?= $col['content'] ?></td>
            <?php endforeach; ?>
            <?php if ($this->details && isset($col)): ?>
              <?php if ($col['details']): ?>
                <td class="body <?= $this->col_last ?> col_last"><a href="<?= $col['url'] ?>"><?= Image::getHtml('assets/contao/images/info.gif') ?></a></td>
              <?php else: ?>
                <td class="body <?= $this->col_last ?> col_last">&nbsp;</td>
              <?php endif; ?>
            <?php endif; ?>
          </tr>
        <?php endforeach; ?>
      </tbody>
      </table>
    
    
      <?= $this->pagination ?>
    
    
    </div>
    Geändert von mandrake (30.04.2017 um 18:16 Uhr)

  2. #2
    Contao-Urgestein Avatar von Andreas
    Registriert seit
    19.06.2009.
    Ort
    Mönchengladbach
    Beiträge
    7.703
    User beschenken
    Wunschliste
    Contao-Projekt unterstützen

    Support Contao

    Standard

    Benutze sowas hier an der entsprechenden Stelle.
    PHP-Code:
    if ($this->total):
    ...
    else:
    echo 
    $GLOBALS['TL_LANG']['CUSTOM']['noListResult']; 
    Lege dir die Sprachvariable in system/config/langconfig.php an.
    Bitte!
    Vor Anfragen im Forum HTML validieren.
    Codesnippets hier im Froum sauber einrücken. Nur Tabs o. nur Leerzeichen verwenden.

    Vielen Dank an alle Wunschlistenerfüller
    Andreas Burg, Web Solutions

  3. #3
    Contao-Fan Avatar von mandrake
    Registriert seit
    19.06.2009.
    Ort
    Düsseldorf
    Beiträge
    461

    Standard

    Top - Danke Dir!

  4. #4
    Contao-Nutzer
    Registriert seit
    10.08.2010.
    Beiträge
    42

    Standard

    Hallo, ich versuche im Moment das gleiche... aber was heißt: an entsprechender Stelle einfügen? Ich bin leider Anfänger und habe keine Ahnung, an welche Stelle ich das einfügen sollte?!
    Danke für Eure Hilfe!!!

  5. #5
    Contao-Urgestein Avatar von Andreas
    Registriert seit
    19.06.2009.
    Ort
    Mönchengladbach
    Beiträge
    7.703
    User beschenken
    Wunschliste
    Contao-Projekt unterstützen

    Support Contao

    Standard

    Erstelle im BE eine Kopie von list_default.html5. Öffne es in deinem Editor mit Syntax-Highlighter und mache dich mit der Logik von PHP in Templates vertraut.
    PHP-Code:
    <?php if ($this->variableString): ?>
      HTML hier wenn variableString nicht leer oder nicht 0
    <?php endif; ?>


    <?php if ($this->variableString): ?>
      HTML wenn variableString etwas enthält
    <?php else: ?>
      HTML wenn variableString leer oder gleich 0 ist
    <?php endif; ?>


    <?php if ($this->variableString == 'foo'): ?>
      HTML wenn variableString foo enthält
    <?php elseif ($this->variableString == 'bar'): ?>
      HTML wenn variableString bar enthält
    <?php endif; ?>


    <?php if ($this->variableString == 'foo'): ?>
      HTML wenn variableString foo enthält
    <?php elseif ($this->variableString == 'bar'): ?>
      HTML wenn variableString bar enthält
    <?php else: ?>
      HTML wenn variableString weder foo noch bar enthält
    <?php endif; ?>


    <?php foreach ($this->variableArray as $variable): ?>
      HTML mit variableArray im Loop
    <?php endforeach; ?>
    Du kannst die Kopie des erstellten Templates auch umbenennen, dann musst du es danach im Auflistungs-Modul aber auswählen.

    Hiermit kannst du dir alle Variablen, welche dieses Template anbietet, ausgeben lassen.
    PHP-Code:
    <?php $this->showTemplateVars(); ?>
    Bitte!
    Vor Anfragen im Forum HTML validieren.
    Codesnippets hier im Froum sauber einrücken. Nur Tabs o. nur Leerzeichen verwenden.

    Vielen Dank an alle Wunschlistenerfüller
    Andreas Burg, Web Solutions

  6. #6
    Contao-Fan Avatar von mandrake
    Registriert seit
    19.06.2009.
    Ort
    Düsseldorf
    Beiträge
    461

    Standard

    Ich habe die Abfrage in das Original Template mit Kommentar eingefügt:

    Code:
    <div class="<?= $this->class ?> ce_table listing block"<?= $this->cssID ?><?php if ($this->style): ?> style="<?= $this->style ?>"<?php endif; ?>>
    
      <?php if ($this->headline): ?>
        <<?= $this->hl ?>><?= $this->headline ?></<?= $this->hl ?>>
      <?php endif; ?>
    
      <?php if ($this->searchable): ?>
        <div class="list_search">
          <form<?php if ($this->action): ?> action="<?= $this->action ?>"<?php endif; ?> method="get">
            <div class="formbody">
              <input type="hidden" name="order_by" value="<?= $this->order_by ?>">
              <input type="hidden" name="sort" value="<?= $this->sort ?>">
              <input type="hidden" name="per_page" value="<?= $this->per_page ?>">
              <label for="ctrl_search" class="invisible"><?= $this->fields_label ?></label>
              <select name="search" id="ctrl_search" class="select">
                <?= $this->search_fields ?>
              </select>
              <label for="ctrl_for" class="invisible"><?= $this->keywords_label ?></label>
              <input type="text" name="for" id="ctrl_for" class="text" value="<?= $this->for ?>">
              <input type="submit" class="submit" value="<?= $this->search_label ?>">
            </div>
          </form>
        </div>
      <?php endif; ?>
    
    <?php if ($this->total): ?> <?php /* Abfrage, ob Suche ein Ergebnis hat */ ?>
    
      <?php if ($this->per_page): ?>
        <div class="list_per_page">
          <form<?php if ($this->action): ?> action="<?= $this->action ?>"<?php endif; ?> method="get">
            <div class="formbody">
              <input type="hidden" name="order_by" value="<?= $this->order_by ?>">
              <input type="hidden" name="sort" value="<?= $this->sort ?>">
              <input type="hidden" name="search" value="<?= $this->search ?>">
              <input type="hidden" name="for" value="<?= $this->for ?>">
              <label for="ctrl_per_page" class="invisible"><?= $this->per_page_label ?></label>
              <select name="per_page" id="ctrl_per_page" class="select">
                <option value="10"<?php if ($this->per_page == 10): ?> selected="selected"<?php endif; ?>>10</option>
                <option value="20"<?php if ($this->per_page == 20): ?> selected="selected"<?php endif; ?>>20</option>
                <option value="30"<?php if ($this->per_page == 30): ?> selected="selected"<?php endif; ?>>30</option>
                <option value="50"<?php if ($this->per_page == 50): ?> selected="selected"<?php endif; ?>>50</option>
                <option value="100"<?php if ($this->per_page == 100): ?> selected="selected"<?php endif; ?>>100</option>
                <option value="250"<?php if ($this->per_page == 250): ?> selected="selected"<?php endif; ?>>250</option>
                <option value="500"<?php if ($this->per_page == 500): ?> selected="selected"<?php endif; ?>>500</option>
              </select>
              <input type="submit" class="submit" value="<?= $this->per_page_label ?>">
            </div>
          </form>
        </div>
      <?php endif; ?>
    
    <?php else: ?>
      <?php echo $GLOBALS['TL_LANG']['CUSTOM']['noListResult']; ?>  <?php /* Meldung ausgeben, wenn Suche kein Ergebnis hat */ ?>
    <?php endif ?>
    
      <table class="all_records">
      <thead>
        <tr>
          <?php foreach ($this->thead as $col): ?>
            <th class="head<?= $col['class'] ?>"><a href="<?= $col['href'] ?>" title="<?= $col['title'] ?>"><?= $col['link'] ?></a></th>
          <?php endforeach; ?>
          <?php if ($this->details): ?>
            <th class="head col_last">&nbsp;</th>
          <?php endif; ?>
        </tr>
      </thead>
      <tbody>
        <?php foreach ($this->tbody as $class=>$row): ?>
          <tr class="<?= $class ?>">
            <?php foreach ($row as $col): ?>
              <td class="body <?= $col['class'] ?>"><?= $col['content'] ?></td>
            <?php endforeach; ?>
            <?php if ($this->details && isset($col)): ?>
              <?php if ($col['details']): ?>
                <td class="body <?= $this->col_last ?> col_last"><a href="<?= $col['url'] ?>"><?= Image::getHtml('assets/contao/images/info.gif') ?></a></td>
              <?php else: ?>
                <td class="body <?= $this->col_last ?> col_last">&nbsp;</td>
              <?php endif; ?>
            <?php endif; ?>
          </tr>
        <?php endforeach; ?>
      </tbody>
      </table>
    
      <?= $this->pagination ?>
    
    </div>
    Dann musst Du noch einen entsprechenden Eintrag in "/system/config/langconfig.php" vornehmen:

    Code:
    if ($GLOBALS['TL_LANGUAGE'] == 'de') {
    
      $GLOBALS['TL_LANG']['CUSTOM']['noListResult'] = '<p>Leider gibt es zu Ihrer Suche keine Treffer.</p>';
    
    }

  7. #7
    Contao-Nutzer
    Registriert seit
    10.08.2010.
    Beiträge
    42

    Standard

    Großartig, vielen lieben Dank! Hat funktioniert und mal wieder einfacher als ich dachte

  8. #8
    Contao-Urgestein Avatar von Andreas
    Registriert seit
    19.06.2009.
    Ort
    Mönchengladbach
    Beiträge
    7.703
    User beschenken
    Wunschliste
    Contao-Projekt unterstützen

    Support Contao

    Standard

    Auch wenn mandrake dir hier sein fertiges Template anbietet, hast du mehr davon, wenn du die PHP-Logik verstehst.

    In diesem Fall würde ich die Sprachvariable für alle Sprachen aufsetzen, dann hättest du in anderen Sprachen zumindestens eine Ausgabe.
    PHP-Code:
    $GLOBALS['TL_LANG']['CUSTOM']['noListResult'] = '<p>Leider gibt es zu Ihrer Suche keine Treffer.</p>'
    Erst wenn du noch eine andere Sprache hast, solltest du unterscheiden.
    PHP-Code:
    // alle Sprachen
    $GLOBALS['TL_LANG']['CUSTOM']['noListResult'] = 'Sorry, no result.';

    // nur DE
    if ($GLOBALS['TL_LANGUAGE'] == 'de') {
      
    $GLOBALS['TL_LANG']['CUSTOM']['noListResult'] = 'Leider gibt es zu Ihrer Suche keine Treffer.';

    Das "<p></p>" gehört eigentlich in die Sprachvariable, denn wenn du mal mehrere Sprachen hättest und wolltest z.B. ein class="no-result" in das P schreiben, müsstest du alle Sprachvariablen bearbeiten. So, kann man dies einmalig im Template erledigen.
    Bitte!
    Vor Anfragen im Forum HTML validieren.
    Codesnippets hier im Froum sauber einrücken. Nur Tabs o. nur Leerzeichen verwenden.

    Vielen Dank an alle Wunschlistenerfüller
    Andreas Burg, Web Solutions

  9. #9
    Contao-Urgestein Avatar von Andreas
    Registriert seit
    19.06.2009.
    Ort
    Mönchengladbach
    Beiträge
    7.703
    User beschenken
    Wunschliste
    Contao-Projekt unterstützen

    Support Contao

    Standard

    Hier noch ein Beispiel, wie man eine Variable mitten in einen String bringen kann.
    PHP-Code:
    <?php
    // langconfig
    $GLOBALS['TL_LANGUAGE']['CUSTOM']['listTotal'] = 'Die Suche ergab %d Treffer.';
    ?>

    Im Template
    <?= sprintf($GLOBALS['TL_LANGUAGE']['CUSTOM']['listTotal'], $this->total); ?>
    "<?= " ist das Gleiche wie "<?php echo ".

    Der Platzhalte für Zahlen (digit) ist %d, für Strings wäre dies %s. http://de1.php.net/manual/de/function.sprintf.php
    Bitte!
    Vor Anfragen im Forum HTML validieren.
    Codesnippets hier im Froum sauber einrücken. Nur Tabs o. nur Leerzeichen verwenden.

    Vielen Dank an alle Wunschlistenerfüller
    Andreas Burg, Web Solutions

Aktive Benutzer

Aktive Benutzer

Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)

Lesezeichen

Lesezeichen

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •