ich bastel mir gerade ein Teaser-Modul zusammen, welches soweit auch schonmal funktioniert. Kategorie kann ausgewählt werden und der Text wird auf eine einstellbare Länge gekürzt. Soweit so gut.
An ein Paar stellen komme ich aber trotz Suche nicht ganz weiter. Mir fehlern da immer noch Programmierkenntnisse.
1. Ich kriege die Verlinkung zum jeweiligen Artikel nicht ganz zusammen.
Bisher bekomme ich immer ein komplette Artikelliste als Ausgabe.
An der Stelle hab ich wohl einen Knoten im Kopf.
2. Die Artikel sollen nach CreateDate sortiert werden, also der neueste oben.
Wo/Wie setze ich da an?
3. Die Textformatierungen via Textile werden nicht übernommen. Gibt es dafür eine Lösung?
Hier der Code der Modulausgabe:
Code: Alles auswählen
<div id="accordion">
<?php
if (!function_exists('truncate'))
{
function truncate($string, $length = 80, $etc = '...', $break_words = false)
{
if ($length == 0)
return '';
if (strlen($string) > $length)
{
$length -= strlen($etc);
if (!$break_words)
$string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length +1));
return substr($string, 0, $length).$etc;
}
else
return $string;
}
}
$cat = OOCategory::getCategoryById('REX_VALUE[1]');
$childs = $cat->getArticles( true);
if ( is_array( $childs))
{
foreach ( $childs as $child)
{
$id = $child->getId();
if ( $id == 25) continue;
$article = new article( $id);
$name = $child->getName();
$date = $child->getCreateDate();
$content = truncate( strip_tags( $article->getArticle()), 'REX_VALUE[2]'); // Anzahl Zeichen
$media = $child->getFileMedia();
print( '<h3>'.$name.'</h3>');
printf( '<div>%s', $content);
{
### Links ab hier ###
$articles = $cat->getArticles( true); // Alle Artikel der Kategorie auslesen, die Online sind
if ( is_array( $articles) && count( $articles) > 0) {
foreach ( $articles as $article) {
// Den aktuellen Artikel nicht verlinken
if ( $article->getId() == REX_ARTICLE_ID) continue;
// Startartikel ausblenden
if ( $article->isStartPage()) continue;
print '<a href="'.$article->getUrl($articleId).'">'.$article->getName().'</a><br />';
}
}
### Links bis hier ####
}
if ( $media != null) {
print '<p style="clear:both";>';
printf( '%s', $media->toHTML());
print '</p>';
}
print( '</div>');
}
}
?>
</div>