-
Newsbox klickbar machen
Hallo!
Ich möchte die Newsbox auf der Startseite (Bild mit Text innerhalb - News Latest) komplett als Link haben.
Dazu habe ich die news_latest.html5 verändert:
Code:
<!--- HINGEZUGEFÜGT --->
<?php if ($this->href): ?>
<a href="<?php echo $this->href; ?>"<?php echo $this->attributes; ?> title="<?php echo $this->alt; ?>">
<?php endif; ?>
<!--- ENDE HINGEZUGEFÜGT --->
<div class="layout_latest block<?php echo $this->class; ?>">
<?php if ($this->hasMetaFields): ?>
<p class="info"><time datetime="<?php echo $this->datetime; ?>"><?php echo $this->date; ?></time> <?php echo $this->author; ?> <?php echo $this->commentCount; ?></p>
<?php endif; ?>
<?php if ($this->addImage): ?>
<figure class="image_container<?php echo $this->floatClass; ?>"<?php if ($this->margin || $this->float): ?> style="<?php echo trim($this->margin . $this->float); ?>"<?php endif; ?>>
<?php if ($this->href): ?>
<a href="<?php echo $this->href; ?>"<?php echo $this->attributes; ?> title="<?php echo $this->alt; ?>">
<?php endif; ?>
<img src="<?php echo $this->src; ?>"<?php echo $this->imgSize; ?> alt="<?php echo $this->alt; ?>">
<?php if ($this->href): ?>
</a>
<?php endif; ?>
<?php if ($this->caption): ?>
<figcaption class="caption" style="width:<?php echo $this->arrSize[0]; ?>px"><?php echo $this->caption; ?></figcaption>
<?php endif; ?>
</figure>
<?php endif; ?>
<h2><?php echo $this->linkHeadline; ?></h2>
<div class="teaser">
<?php echo $this->teaser; ?>
<?php if ($this->text): ?>
<p class="more"><?php echo $this->more; ?></p>
<?php endif; ?>
</div>
</div>
<!--- HINGEZUGEFÜGT --->
<?php if ($this->href): ?>
</a>
<?php endif; ?>
<!--- ENDE HINGEZUGEFÜGT --->
jedoch funktioniert das so nicht.
Es gibt kein "($this->href)" - also keinen LInk der da eingebaut werden kann.
Wie kann ich den Link zur Detailansicht einfügen?
Danke
-
wäre dafür nicht ein insert_tag auf das Ziel eine Alternative?
HTML Element mit {{link.....}}
-
hi magicsepp
ich habs getestet:
jedoch geht dann die box link auf http://myweb.com/newsdetail/
anstatt (wie zb beim klick auf die überschrift oder "weiter")
auf http://myweb.com/newsdetail/items/news-title
-
dann verwende doch den more link aus
PHP-Code:
<?php echo $this->more; ?>
-
wie meinst du das genau?
Code:
<?php echo $this->more; ?>
fügt ja folgendes ein
Code:
<a href="....." title="...">
Weiterlesen...
<span class="invisible"> ...</span>
</a>
wie komm ich ran an den teil der im href steht?
sorry bin kein php genie...
-
-
super spitze!! hat geklappt
vielen dank!!
-
Es klappt nicht
Liebe Leute,
bei mir klappt es leider nicht. Etwas mache ich sicherlich falsch. Könnt ihr mir da bitte helfen? Danke.
Code:
<!--- HINGEZUGEFÜGT --->
<?php if ($this->link): ?>
<a href="<?php echo $this->link; ?>">
<?php endif; ?>
<!--- ENDE HINGEZUGEFÜGT --->
<div class="layout_short block<?php echo $this->class; ?>">
<?php if ($this->hasMetaFields): ?>
<p class="info"><time datetime="<?php echo $this->datetime; ?>"><?php echo $this->date; ?></time> <?php echo $this->author; ?> <?php echo $this->commentCount; ?></p>
<?php endif; ?>
<h2><?php echo $this->linkHeadline; ?></h2>
<div class="teaser">
<?php echo $this->teaser; ?>
</div>
<?php if ($this->text): ?>
<p class="more"><?php echo $this->more; ?></p>
<?php endif; ?>
</div>
<!--- HINGEZUGEFÜGT --->
<?php if ($this->link): ?>
</a>
<?php endif; ?>
<!--- ENDE HINGEZUGEFÜGT --->
Ich habe es in der news_short-Vorlage.
Liebe Grüße,
Jan
-
ich könnte dir nur eine javascript-lösung anbieten, hier am beispiel der news_late
Code:
<div class="layout_latest block<?php echo $this->class; ?>" onclick="window.location='<?php echo $this->link; ?>';">
.
.
.
</div>
-
der link ist in wird vorzeitig vom </a> aus $this->more zu früh geschlossen....
-
this -> link müsst denk ist stimmen - zumindest in contao 3.0.5 hab ichs so in verwendung
mein code aus dem template news_latest
Vorsicht - ich arbeite hier ohne if . da ich auf jeden fall zu einer detailseite gehen möchte - ein link wird grundsätzlich nur erstellt wenn es mehr als den teaser gibt - wenn es keinen weiten inhalt gibt wird der link trotzdem funktionieren und auf die detailseite gerichtet wo dann nochmal der teaser zu lesen ist ..
Vorsicht2 .. es ist auch noch etwas anders verändert im template...
Code:
<!--- HINGEZUGEFÜGT --->
<a href="<?php echo $this->link; ?>">
<!--- ENDE HINGEZUGEFÜGT --->
<div class="layout_latest block<?php echo $this->class; ?>">
<?php if ($this->hasMetaFields): ?>
<p class="info"><time datetime="<?php echo $this->datetime; ?>"><?php echo $this->date; ?></time> <?php echo $this->author; ?> <?php echo $this->commentCount; ?></p>
<?php endif; ?>
<?php if ($this->addImage): ?>
<figure class="image_container<?php echo $this->floatClass; ?>"<?php if ($this->margin || $this->float): ?> style="<?php echo trim($this->margin . $this->float); ?>"<?php endif; ?>>
<?php if ($this->href): ?>
<a href="<?php echo $this->href; ?>"<?php echo $this->attributes; ?> title="<?php echo $this->alt; ?>">
<?php endif; ?>
<img src="<?php echo $this->src; ?>"<?php echo $this->imgSize; ?> alt="<?php echo $this->alt; ?>">
<?php if ($this->href): ?>
</a>
<?php endif; ?>
<?php if ($this->caption): ?>
<figcaption class="caption" style="width:<?php echo $this->arrSize[0]; ?>px"><?php echo $this->caption; ?></figcaption>
<?php endif; ?>
</figure>
<?php endif; ?>
<h2><?php echo $this->linkHeadline; ?></h2>
<!--- HINGEZUGEFÜGT --->
<div class="teaser">
<!--- ENDE HINGEZUGEFÜGT --->
<div class="teasertext"><?php echo $this->teaser; ?>
<!--- HINGEZUGEFÜGT ---> </div><!--- ENDE HINGEZUGEFÜGT --->
<?php if ($this->text): ?>
<p class="more"><?php echo $this->more; ?></p>
<?php endif; ?>
</div>
</div>
<!--- HINGEZUGEFÜGT --->
</a>
<!--- ENDE HINGEZUGEFÜGT --->
-
Vielen Dank.
Leider wird bei mir (3.1.0) der a-Tag automatisch geschlossen und mehrmals danach automatisch hinzugefügt. Es scheint, dass irgendwo in Contao dieser Automatismus eingestellt ist.
Folgender Code wird erzeugt:
HTML-Code:
<div class="mod_newslist grauerHintergrund grid4 block">
<h1>News</h1>
<span class="nachLinie">—</span>
<!--- HINGEZUGEFÜGT --->
<a href="news/die-wunderbare-welt-des-dokumentarfilms-werkschau-britta-wauer.html">
<!--- ENDE HINGEZUGEFÜGT --->
</a><div class="layout_short block first even"><a href="news/die-wunderbare-welt-des-dokumentarfilms-werkschau-britta-wauer.html">
<p class="info"><time datetime="2013-05-10T00:00:00+00:00">10.05.2013 00:00</time> </p>
</a><h2><a href="news/die-wunderbare-welt-des-dokumentarfilms-werkschau-britta-wauer.html"></a><a href="news/die-wunderbare-welt-des-dokumentarfilms-werkschau-britta-wauer.html" title="Den Artikel lesen: Die wunderbare Welt des Dokumentar- films - Werkschau Britta Wauer">Die wunderbare Welt des Dokumentar- films - Werkschau Britta Wauer</a></h2>
<div class="teaser">
<div class="page" title="Page 1">
<div class="layoutArea">
<div class="column">
<p>Vorgestellt von Steffen Reiche<br>Januar – Mai 2013<br>Jochen-Klepper-Saal, Berlin-Nikolassee<br>Freitag, 10. Mai 19 Uhr<br>Im Himmel, unter der Erde</p>
</div>
</div>
</div> </div>
<p class="more"><a href="news/die-wunderbare-welt-des-dokumentarfilms-werkschau-britta-wauer.html" title="Den Artikel lesen: Die wunderbare Welt des Dokumentar- films - Werkschau Britta Wauer">Weiterlesen … <span class="invisible">Die wunderbare Welt des Dokumentar- films - Werkschau Britta Wauer</span></a></p>
</div>
<!--- HINGEZUGEFÜGT --->
<!--- ENDE HINGEZUGEFÜGT ---><!--- HINGEZUGEFÜGT --->
<a href="news/tutanchamun-sein-grab-und-die-schaetze.html">
<!--- ENDE HINGEZUGEFÜGT --->
</a><div class="layout_short block last odd"><a href="news/tutanchamun-sein-grab-und-die-schaetze.html">
<p class="info"><time datetime="2013-05-08T00:00:00+00:00">08.05.2013 00:00</time> </p>
</a><h2><a href="news/tutanchamun-sein-grab-und-die-schaetze.html"></a><a href="news/tutanchamun-sein-grab-und-die-schaetze.html" title="Den Artikel lesen: Tutanchamun – Sein Grab und die Schätze">Tutanchamun – Sein Grab und die Schätze</a></h2>
<div class="teaser">
<p>Die große Ausstellung zur<br>archäologischen<br>Weltsensation<br>Mit den Filmen von Britzka<br>jetzt in Prag und Berlin (ARENA)! </p> </div>
<p class="more"><a href="news/tutanchamun-sein-grab-und-die-schaetze.html" title="Den Artikel lesen: Tutanchamun – Sein Grab und die Schätze">Weiterlesen … <span class="invisible">Tutanchamun – Sein Grab und die Schätze</span></a></p>
</div>
<!--- HINGEZUGEFÜGT --->
<!--- ENDE HINGEZUGEFÜGT --->
</div>
-
Ahja das hatte ich auch
das passiet nicht weil es 3.1 ist sondern weil drinnen in dem bereich noch ein <a> !
deshalb hab ich das eingefügt:
Code:
<p class="more"><?php echo $this->more; ?></p>
statt dem link mittendrinnen... hast du das?
grad gefunden:
Code:
<?php if ($this->link): ?>
muss raus!!! da es ja nochmal einen link erzeugt und somit den anderen schließt
-
Super, danke. ich habe es raus und es funkt! Vielen lieben Dank für die schnelle und wertvolle Hilfe.
Mach es gut.
Jan
-
Und
Hi Jenda,
kannst Du mal den Code der funktioniert posten?