Das einrichten eines RSS-feeds mit dieser Anleitung ist ja ziemlich aufwändig, und funktioniert hat es bei mir auch nicht. Also habe ich mein altes RSS-script und das Teaser Script (das ich auch etwas erweitert habe) und baue sich ein RSS-Modul das wie der Teaser die Einträge einer beliebigen Kategorie ausliest und einen (laut http://feedvalidator.org/ valieden) RSS 9.1 feed daraus macht. Es muss nur als Modul eingebunden werden, und ohne Template einem Artikel zugewiesen werden.
Also falls jemand Interesse hat kann er es testen und sagen was er davon hält.
Eingabe
Code: Alles auswählen
<strong>Kategorie ID - oder lehr lassen für die aktuelle Kategorie</strong><br />
<input name="VALUE[1]" value="REX_VALUE[1]" class="inp100" /><br />
<br />
<strong>Anzahl der Artikel</strong><br />
<input name="VALUE[2]" value="REX_VALUE[2]" class="inp100" /><br />
<br />
<strong>Anzahl der Wörter pro Artikel</strong><br />
<input name="VALUE[3]" value="REX_VALUE[3]" class="inp100" /><br />
<br />
<strong>Sortierung</strong><br />
<select name="VALUE[4]" class="inp100">
<option value='1' <? if ("REX_VALUE[4]" == '1') echo 'selected="selected"'; ?>>nach Update-Datum sortieren (sortArticlesByUpdateDate)</option>
<option value='2' <? if ("REX_VALUE[4]" == '2') echo 'selected="selected"'; ?>>nach Update-Datum umgekehrt sortieren (sortArticlesByUpdateDate_rev)</option>
<option value='3' <? if ("REX_VALUE[4]" == '3') echo 'selected="selected"'; ?>>Nach Priorität sortieren (sortArticlesByPrio)</option>
<option value='4' <? if ("REX_VALUE[4]" == '4') echo 'selected="selected"'; ?>>Nach Priorität umgekehrt sortieren (sortArticlesByPrio_rev)</option>
</select>
<br />
<br />
<label><input type="checkbox"<?php if("REX_VALUE[5]" == 1){ echo ' checked="checked"';}?> name="VALUE[5]" value="1">
<strong>Überschriften entfernen</strong></label><br />
Ausgabe
Code: Alles auswählen
<?php
//---Module by----------------------
//-- franz007.at
//-- franz007
//-- www.franz007.at
//----------------------------------
$rss_title = "franz007.at Newsfeed"; // titel des RSS-feeds
$rss_link = "http://www.franz007.at/"; // link
$rss_description = "franz007.at"; // beschreibung des feeds
$rss_language = "de-at"; //language code
$domain = "http://www.franz007.at/"; # inkl http:// und abschließendem / wird in den Links vor rex_getUrl($articleId) gesetzt
$n = "\n";
function un_htmlentities($string){
$trans_tbl = get_html_translation_table (HTML_ENTITIES);
$trans_tbl = array_flip($trans_tbl);
return strtr($string, $trans_tbl);
}
if (!function_exists(sortArticlesByUpdateDate)) {
function sortArticlesByUpdateDate( $artA, $artB) {
$createA = $artA->_updatedate;
$createB = $artB->_updatedate;
if ( $createA == $createB) {
return 0;
}
return $createA > $createB ? -1 : 1;
}
}
if (!function_exists(sortArticlesByUpdateDate_rev)) {
function sortArticlesByUpdateDate_rev( $artA, $artB) {
$createA = $artA->_updatedate;
$createB = $artB->_updatedate;
if ( $createA == $createB) {
return 0;
}
return $createA > $createB ? +1 : 1;
}
}
if (!function_exists(sortArticlesByPrio)) {
function sortArticlesByPrio( $artA, $artB) {
$createA = $artA->_prior;
$createB = $artB->_prior;
if ( $createA == $createB) {
return 0;
}
return $createA > $createB ? +1 : 1;
}
}
if (!function_exists(sortArticlesByPrio_rev)) {
function sortArticlesByPrio_rev( $artA, $artB) {
$createA = $artA->_prior;
$createB = $artB->_prior;
if ( $createA == $createB) {
return 0;
}
//return $createA > $createB ? +1 : 1;
return $createA > $createB ? -1 : 1;
}
}
if (!$REX['REDAXO']){ #nicht im backend
header("Content-type: application/xml");
echo '<'.'?xml version="1.0" encoding="ISO-8859-1" ?'.'>';
echo '<rss version="0.91">'.$n;
echo '<channel>'.$n;
echo '<title>'.$rss_title.'</title>'.$n;
echo '<link>'.$rss_link.'</link>'.$n;
echo '<description>'.$rss_description.'</description>'.$n;
echo '<language>'.$rss_language.'</language>'.$n;
$itemsPerSide = "REX_VALUE[2]";
$wordsPerArticle = "REX_VALUE[3]";
#$start = !empty($_GET['start']) ? (int) $_GET['start'] : 0; // Startitem
#$offset = $itemsPerSide; // 10 Items pro Seite
if("REX_VALUE[1]" != ""){
$cats = array("REX_VALUE[1]");
}
else{
$cats = array("REX_CATEGORY_ID"); // aktuelle Kategorien "indizieren"
}
$articles = array();
foreach ( $cats as $catId) {
$cat = OOCategory::getCategoryById( $catId);
// CatIds die nicht funktionieren aussortieren
if( $cat === null) {
continue;
}
$cat_articles = $cat->getArticles( true);
foreach ( $cat_articles as $ooarticle) {
// keine Startartikel anzeigen
if ( $ooarticle->isStartPage()) {
continue;
}
// Damit keine Endlosschleife passiert, den Artikel der die Pagination setzt überspringen
if ( $ooarticle->getId() == REX_ARTICLE_ID) {
continue;
}
$articles[] = $ooarticle;
}
}
$articles_length = count( $articles);
// Sortieren
if ( $articles_length > 0) {
if("REX_VALUE[4]" == "1"){// Sortieren nach Erstellungsdatum
usort( $articles, "sortArticlesByUpdateDate");
}
if("REX_VALUE[4]" == "2"){// Sortieren nach Erstellungsdatum
usort( $articles, "sortArticlesByUpdateDate_rev");
}
if("REX_VALUE[4]" == "3"){// Sortieren nach Priorität
usort( $articles, "sortArticlesByPrio");
}
if("REX_VALUE[4]" == "4"){// Sortieren nach Priorität (umgekehrt)
usort( $articles, "sortArticlesByPrio_rev");
}
}
#$article_list = array_slice( $articles, $start, $offset);
#foreach ( $article_list as $ooarticle) {
foreach ( $articles as $ooarticle) {
if ($ooarticle->isOnline(true)) {
$articleId = $ooarticle->getId();
$article = new article();
$article->setArticleId( $articleId);
$articleContent = $article->getArticle();
if('REX_VALUE[5]' == "1"){//bilder entfernen
//überschriften entfernen
$articleContent = preg_replace("/<h[1-6]>.*<\/h[1-6]>/", "", $articleContent);
}
//alle tags entfernen
$articleContent = strip_tags($articleContent);
$articleContent = un_htmlentities($articleContent);
$output = "";
$words = explode(" ",$articleContent);
$wordsCount = count($words);
if ($wordsCount < $wordsPerArticle) {
$wEnd = $wordsCount;
}
else{
$wEnd = $wordsPerArticle;
$cutted = true;
}
for ($w=0;$w<$wEnd;$w++) {
$output .= $words[$w]." ";
}
// Leerzeichen entfernen am Anfang und Ende des Strings
$output = trim($output);
$item_description = $output;
// " ..." anhängen wenn der artikel gekürzt wird
if($cutted = true){
$item_description .= " ...";
}
$item_title = $ooarticle->getName();
$item_link = $domain.rex_getUrl($articleId);
$item_title = "<![CDATA[".$item_title." ]]>";
$item_description = strip_tags($item_description);
$item_description = un_htmlentities($item_description);
$item_description = "<![CDATA[".$item_description."]]> ";
#eintrag ausgeben
echo '<item>'.$n;
echo '<title>';
echo $item_title;
echo '</title>'.$n;
echo '<description>'.$item_description.'</description>'.$n;
echo '<link>';
echo $item_link;
echo '</link>'.$n;
echo '</item>'.$n;
}
}
echo '</channel>'.$n;
echo '</rss>'.$n;
}
else{ //im backend
echo "RSS-feed";
}
?>