Ergebnis 1 bis 6 von 6

Thema: Template anpassen

  1. #1
    Contao-Fan
    Registriert seit
    15.12.2011.
    Beiträge
    812

    Standard Template anpassen

    Hallo zusammen,

    ich habe eine Seite in der ich via Event-List alle Events anzeigen lasse (auch die abgelaufenen). Nun möchte ich gerne, dass wenn ein Event abgelaufen ist, dass das alte Datum (Beispiel: 26.10.2021) ausgeblendet wird und dafür ein Alternativ Text angezeigt wird.

    Vom Verständnis her würde ich das im Template machen, aber, da ich keine Programmierkenntnisse habe, fehlt mir der passende Code.
    Könnt ihr mir da helfen?

    Die Position des Alternativtextes soll an der selben Position wie das Datum sein. Es soll dann drin stehen: "JETZT VORMERKEN"

    Gruß und Danke,
    Preetz

  2. #2
    Contao-Nutzer Avatar von Black Pirate
    Registriert seit
    10.02.2015.
    Beiträge
    224

    Standard

    Du könntest per Datum eine Abfrage einbauen.

    Code:
    <?php 
    /* Datum ermitteln, dein Datumsformat */
    $heute = date("d.m.Y"); 
    ?>
    
    <?php if ($this->header): ?>
      <div class="header<?= $this->classHeader ?>">
        <?php if ($this->firstDay): ?><span class="day"><?= $this->firstDay ?>, </span><?php endif; ?><span class="date"><?= $this->firstDate ?></span>
      </div>
    <?php endif; ?>
    
    <div class="event layout_list<?= $this->classList ?>" itemscope itemtype="http://schema.org/Event">
    
      <h2 itemprop="name"><a href="<?= $this->href ?>" title="<?= $this->title ?> (<?php if ($this->day): ?><?= $this->day ?>, <?php endif; ?><?= $this->date ?><?php if ($this->time): ?> <?= $this->time ?><?php endif; ?>)"<?= $this->target ?> itemprop="url"><?= $this->link ?></a></h2>
     
    <?php
    /* Abfrage ob Datum grösser oder gleich Heute ist */
    if ($this->date >= $heute):
    ?>
    <p class="time"><time datetime="<?= $this->datetime ?>" itemprop="startDate"><?= $this->date ?><?php if ($this->time): ?> <?= $this->time ?><?php endif; ?></time></p>
    <?php else: ?>
    <p>Dein Text</p>
    <?php endif; ?>
    
      <?php if ($this->location): ?>
        <p class="location" itemprop="location" itemscope itemtype="http://schema.org/Place">
          <span itemprop="name"><?= $this->location ?></span>
          <?php if ($this->address): ?>
            (<span itemprop="address" itemscope itemtype="http://schema.org/PostalAddress"><?= $this->address ?></span>)
          <?php endif; ?>
        </p>
      <?php endif; ?>
    
      <?php if ($this->addImage): ?>
        <?php $this->insert('image', $this->arrData); ?>
      <?php endif; ?>
    
      <?php if ($this->hasDetails): ?>
        <?= $this->details ?>
      <?php else: ?>
        <div class="ce_text block" itemprop="description">
          <?= $this->teaser ?>
      </div>
      <?php endif; ?>
    
    </div>
    ungetestet ... aber so ungefähr

  3. #3
    Contao-Fan
    Registriert seit
    15.12.2011.
    Beiträge
    812

    Standard

    Vielen Dank für den Code.
    Bis jetzt komme ich aber noch nicht zu meinem Ergebnis.

    Ich benötige die Funktion zwei Mal.

    Template-List (hier habe ich es versucht an "passender Stelle" einzufügen:
    HTML-Code:
    <?php /*if ($this->header): ?>
      <div class="header<?= $this->classHeader ?>">
        <?php if ($this->firstDay): ?><span class="day"><?= $this->firstDay ?>, </span><?php endif; ?><span class="date"><?= $this->firstDate ?></span>
      </div>
    <?php endif; */ ?>
    
    <?php 
    /* Datum ermitteln, dein Datumsformat */
    $heute = date("d.m.Y"); 
    ?>
    
    <div class="event layout_teaser<?= $this->classUpcoming ?> col s12 m6">
      <div class="inner">
    
    	  <?php if ($this->addImage): ?>
    	    <figure class="image_container<?= $this->floatClass ?>"<?php if ($this->margin): ?> style="<?= $this->margin ?>"<?php endif; ?>>
    
    	      <?php if ($this->href): ?>
    	        <a href="<?= $this->href ?>"<?= $this->attributes ?> title="<?= $this->alt ?>">
    	      <?php endif; ?>
    
    	      <?php $this->insert('picture_default', $this->picture); ?>
    
    	      <?php if ($this->href): ?>
    	        </a>
    	      <?php endif; ?>
    
    	      <?php if ($this->caption): ?>
    	        <figcaption class="caption"><?= $this->caption ?></figcaption>
    	      <?php endif; ?>
    
    	    </figure>
    	  <?php endif; ?>
    
    
    
    
    
    	  <div class="text">
    		  <?php if ($this->hasDetails): ?>
    		    <h2><a href="<?= $this->href ?>" title="<?= $this->title ?> (<?php if ($this->day) echo $this->day . ', '; ?><?= $this->date ?><?php if ($this->time) echo ', ' . $this->time; ?>)"<?= $this->target ?>><?= $this->link ?></a></h2>
    		  <?php else: ?>
    		    <h2><?= $this->title ?></h2>
    		  <?php endif; ?>
    
    
    
    
     
    <?php
    /* Abfrage ob Datum grösser oder gleich Heute ist */
    if ($this->date >= $heute):
    ?>
    <p class="time"><time datetime="<?= $this->datetime ?>" itemprop="startDate"><?= $this->date ?><?php if ($this->time): ?> <?= $this->time ?><?php endif; ?></time></p>
    <?php else: ?>
    <p>Dein Text</p>
    <?php endif; ?>
    
    
    
    
    
    		  <p class="time"><time datetime="<?= $this->datetime ?>"><?= str_replace("–"," – ",$this->date) ?><?php if ($this->time): ?>, <?= $this->time ?><?php endif; ?></time></p>
    
    		  <div class="teaser">
    		    <?= $this->teaser ?>
    		  </div>
    
    		  <?php if ($this->hasDetails): ?>
    		  	<a class="more" href="<?= $this->href ?>"><?= $this->more ?></a>
    		  <?php endif; ?>
    	  </div>
    
      </div>
    </div>
    Ich benötige es dann noch in Template_full.

    Kannst du mir vielleicht noch mal helfen?

    Vielen Dank,
    Preetz

  4. #4
    Contao-Nutzer Avatar von Black Pirate
    Registriert seit
    10.02.2015.
    Beiträge
    224

    Standard

    Müsste eigentlich an der gleichen Stelle rein denk ich mal so spontan.
    Der Unterschied von Teaser, Full, etc. ist ja nur abgespeckt oder komplette Daten.

    In deinem Code ist noch ein Fehler, du hast zuunterst nochmal den Datum-Satz drin.
    (oberhalb vom Teaser Aufruf)

    Somit würde zuerst die Abfrage nach dem Datum kommen und dann trotzdem die Datumsanzeige.

    Poste doch mal deine 2 Templates, dann ist es einfacher für mich dir zu helfen

  5. #5
    Contao-Fan
    Registriert seit
    15.12.2011.
    Beiträge
    812

    Standard

    gerne!


    Template "List":
    HTML-Code:
    <?php /*if ($this->header): ?>
      <div class="header<?= $this->classHeader ?>">
        <?php if ($this->firstDay): ?><span class="day"><?= $this->firstDay ?>, </span><?php endif; ?><span class="date"><?= $this->firstDate ?></span>
      </div>
    <?php endif; */ ?>
    
    <?php 
    /* Datum ermitteln, dein Datumsformat */
    $heute = date("d.m.Y"); 
    ?>
    
    <div class="event layout_teaser<?= $this->classUpcoming ?> col s12 m6">
      <div class="inner">
    
    	  <?php if ($this->addImage): ?>
    	    <figure class="image_container<?= $this->floatClass ?>"<?php if ($this->margin): ?> style="<?= $this->margin ?>"<?php endif; ?>>
    
    	      <?php if ($this->href): ?>
    	        <a href="<?= $this->href ?>"<?= $this->attributes ?> title="<?= $this->alt ?>">
    	      <?php endif; ?>
    
    	      <?php $this->insert('picture_default', $this->picture); ?>
    
    	      <?php if ($this->href): ?>
    	        </a>
    	      <?php endif; ?>
    
    	      <?php if ($this->caption): ?>
    	        <figcaption class="caption"><?= $this->caption ?></figcaption>
    	      <?php endif; ?>
    
    	    </figure>
    	  <?php endif; ?>
    
    
    
    
    
    	  <div class="text">
    		  <?php if ($this->hasDetails): ?>
    		    <h2><a href="<?= $this->href ?>" title="<?= $this->title ?> (<?php if ($this->day) echo $this->day . ', '; ?><?= $this->date ?><?php if ($this->time) echo ', ' . $this->time; ?>)"<?= $this->target ?>><?= $this->link ?></a></h2>
    		  <?php else: ?>
    		    <h2><?= $this->title ?></h2>
    		  <?php endif; ?>
    
    
    
    
     
    <?php
    /* Abfrage ob Datum grösser oder gleich Heute ist */
    if ($this->date >= $heute):
    ?>
    <p class="time"><time datetime="<?= $this->datetime ?>" itemprop="startDate"><?= $this->date ?><?php if ($this->time): ?> <?= $this->time ?><?php endif; ?></time></p>
    <?php else: ?>
    <p>Dein Text</p>
    <?php endif; ?>
    
    
    
    
    
    		  <p class="time"><time datetime="<?= $this->datetime ?>"><?= str_replace("–"," – ",$this->date) ?><?php if ($this->time): ?>, <?= $this->time ?><?php endif; ?></time></p>
    
    		  <div class="teaser">
    		    <?= $this->teaser ?>
    		  </div>
    
    		  <?php if ($this->hasDetails): ?>
    		  	<a class="more" href="<?= $this->href ?>"><?= $this->more ?></a>
    		  <?php endif; ?>
    	  </div>
    
      </div>
    </div>


    Template "full":
    HTML-Code:
    <div class="event layout_full block<?= $this->class ?>" itemscope itemtype="http://schema.org/Event">
    
      <h1 itemprop="name"><?= $this->title ?>
    
      </h1>
    
      <?php if ($this->recurring): ?>
        <p class="info recurring"><?= $this->recurring ?></p>
      <?php else: ?>
        <p class="info"><time datetime="<?= $this->datetime ?>" itemprop="startDate"><?= $this->date ?><?php if ($this->time): ?> <?= $this->time ?><?php endif; ?></time></p>
      <?php endif; ?>
    
      <?php if ($this->location): ?>
        <p class="location" itemprop="location" itemscope itemtype="http://schema.org/Place">
          <span itemprop="name"><?= $this->location ?></span>
          <?php if ($this->address): ?>
            (<span itemprop="address" itemscope itemtype="http://schema.org/PostalAddress"><?= $this->address ?></span>)
          <?php endif; ?>
        </p>
      <?php endif; ?>
    
      <?php if ($this->details): ?>
        <?= $this->details ?>
      <?php else: ?>
        <div class="ce_text block">
          <?php if (!$this->addBefore): ?>
            <?= $this->teaser ?>
          <?php endif; ?>
    
          <?php if ($this->addImage): ?>
            <?php $this->insert('image', $this->arrData); ?>
          <?php endif; ?>
    
          <?php if ($this->addBefore): ?>
            <?= $this->teaser ?>
          <?php endif; ?>
        </div>
      <?php endif; ?>
    
      <?php if ($this->enclosure): ?>
        <ul class="enclosure">
          <?php foreach ($this->enclosure as $enclosure): ?>
            <li class="download-element ext-<?= $enclosure['extension'] ?>">
               <a href="<?= $enclosure['href'] ?>" title="<?= $enclosure['title'] ?>"><?= $enclosure['link'] ?> <span class="size">(<?= $enclosure['filesize'] ?>)</span></a>
            </li>
          <?php endforeach; ?>
        </ul>
      <?php endif; ?>
    
    
      <?php if ($this->reginfo): ?>
        
        
        <?php endif; ?>
        <?php if ($this->regform): ?>
        <div class="WhatEverCssClass">
            <?= $this->regform ?>
        </div>
        <hr>
        <?php endif; ?>
    
    </div>

  6. #6
    Contao-Nutzer Avatar von Black Pirate
    Registriert seit
    10.02.2015.
    Beiträge
    224

    Standard

    Mich dünkt du hast bei deinem Template "List" einiges durcheinander gebracht. da hats Zeilen von "List", "Teaser" und "Upcoming" drin.

    Hab dir jetzt mal die entsprechenden Zeilen in die Original-Templates eingefügt.
    Anpassungen wie zB. dein RegForm musst du dann halt wieder selber rein schreiben.
    Angehängte Dateien Angehängte Dateien

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
  •