NAVIGATION
This shows you the differences between two versions of the page.
|
deutsch:andere-erweiterungen:rss-newsfeed [2012/09/03 16:45] Robert |
deutsch:andere-erweiterungen:rss-newsfeed [2018/06/03 18:09] (current) |
||
|---|---|---|---|
| Line 5: | Line 5: | ||
| ---- | ---- | ||
| Forum: [[http://forum.phpwcms.org/viewtopic.php?f=16&t=17842&p=136700]] \\ | Forum: [[http://forum.phpwcms.org/viewtopic.php?f=16&t=17842&p=136700]] \\ | ||
| + | Webseite: [[http://www.enym.com/artikel/20121211-54/rss-feed-fuer-news-items-in-phpwcms.html]] \\ | ||
| Danke an: Marceau & phalancs für diese Lösung\\ | Danke an: Marceau & phalancs für diese Lösung\\ | ||
| \\ | \\ | ||
| **Autor:** Robert\\ | **Autor:** Robert\\ | ||
| + | **Version:** r528 und kleiner | ||
| Verzeichnis: /\\ | Verzeichnis: /\\ | ||
| ===== Beschreibung ===== | ===== Beschreibung ===== | ||
| - | Mit diesem Script ist es möglich aus den News einen RSS-Feed zu generieren. Die Datei kann manuell oder durch einbindung in bspw. die index.php generiert werden. | + | Mit diesem Script ist es möglich aus den News einen RSS-Feed zu generieren. |
| - | <code php|h Datei mit dem Inhalt erstellen:|h> | + | |
| + | ==== V1.5 ==== | ||
| + | Diese Version generiert zur Laufzeit einen RSS Feed der News und gibt ihn aus. | ||
| + | Anpassung sind in den ersten fünf Zeile bei CONFIGURATION vorzunehmen. | ||
| + | |||
| + | <code php|h news_rss.php V1.5 - Erzeugung zur Laufzeit:|h> | ||
| + | <? | ||
| + | function mkRSS () { | ||
| + | |||
| + | //CONFIGURATION | ||
| + | $news_aid = 54; //ARTICLEID OF NEWSARTICLE | ||
| + | $news_alias = "artikel"; //ARTICLEALIAS OF NEWSARTICLE | ||
| + | $title = "RSS FEED"; | ||
| + | $description = "Newsfeed - ".$_SERVER['SERVER_NAME']; | ||
| + | //END OF CONFIGURATION | ||
| + | |||
| + | //======================================================= | ||
| + | |||
| + | require_once ('config/phpwcms/conf.inc.php'); | ||
| + | |||
| + | $itemTitle = "cnt_title"; | ||
| + | $itemText = "cnt_teasertext"; | ||
| + | $itemDate = "cnt_created"; | ||
| + | $itemOwner = "cnt_editor"; | ||
| + | $itemAlias = "cnt_alias"; | ||
| + | |||
| + | $sql="SELECT * FROM phpwcms_content WHERE cnt_module = 'news' AND cnt_status = 1 ORDER BY cnt_created DESC;"; | ||
| + | |||
| + | //Erzeugen des RSS-Inhaltes: encoding='UTF-8' | ||
| + | $rssHeader='<?xml version="1.0" encoding="ISO-8859-1" ?> | ||
| + | <rss version="2.0"> | ||
| + | <channel> | ||
| + | <title>'.$title.'</title> | ||
| + | <description>'.$description.'</description> | ||
| + | <language>'.$phpwcms['default_lang'].'</language> | ||
| + | <link>'.$phpwcms['site'].'</link> | ||
| + | '; | ||
| + | |||
| + | $rssFooter='</channel> | ||
| + | </rss>'; | ||
| + | |||
| + | //GET DATA | ||
| + | $dbLink = mysql_connect ($phpwcms['db_host'],$phpwcms['db_user'],$phpwcms['db_pass']) or die (mysql_error()); | ||
| + | $setdb = mysql_select_db($phpwcms['db_table'],$dbLink) or die (mysql_error()); | ||
| + | $result=mysql_query($sql,$dbLink) or die(mysql_error()); | ||
| + | |||
| + | $content=$rssHeader; | ||
| + | |||
| + | while($row=mysql_fetch_array($result)){ | ||
| + | |||
| + | $row[$itemText] = str_replace("ü","ü",$row[$itemText]); | ||
| + | $row[$itemText] = str_replace("ü","ü",$row[$itemText]); | ||
| + | $row[$itemText] = str_replace("ö","ö",$row[$itemText]); | ||
| + | $row[$itemText] = str_replace("ä","ä",$row[$itemText]); | ||
| + | $row[$itemText] = str_replace("ä","ä",$row[$itemText]); | ||
| + | $row[$itemText] = str_replace("ß","ss",$row[$itemText]); | ||
| + | $row[$itemText] = str_replace("<p>","",$row[$itemText]); | ||
| + | $row[$itemText] = str_replace("</p>","",$row[$itemText]); | ||
| + | //$row[$itemText] = str_replace(" />",">",$row[$itemText]); | ||
| + | //$row[$itemText] = str_replace("<br>","",$row[$itemText]); | ||
| + | //$row[$itemText] = str_replace("</div>","",$row[$itemText]); | ||
| + | //$row[$itemText] = preg_replace("(<img src=|border=|width=|height=|style=|alt=|title= >)","",$row[$itemText]); | ||
| + | |||
| + | $titel=substr ($row[$itemTitle], 0, 150); | ||
| + | $text=substr ($row[$itemText], 0, 1000); | ||
| + | |||
| + | $itemLink= $phpwcms['site']; | ||
| + | |||
| + | $itemdate1 = date("Ymd", $row[$itemDate]); | ||
| + | $itemDate2 = date("D, d M Y H:i:s O", $row[$itemDate]); | ||
| + | |||
| + | $itemLink = $phpwcms['site'].'index.php?'.$news_alias.'&newsdetail='.$itemdate1.'-'.$news_aid.'_'.rawurlencode($row[$itemAlias]); | ||
| + | |||
| + | $content .= "<item> | ||
| + | <title>".$titel."</title> | ||
| + | <description><![CDATA[".$text."]]></description> | ||
| + | <link>$itemLink</link> | ||
| + | <author>$row[$itemOwner]</author> | ||
| + | <pubDate>$itemDate2</pubDate> | ||
| + | </item> | ||
| + | "; | ||
| + | } | ||
| + | |||
| + | $content.=$rssFooter; | ||
| + | |||
| + | |||
| + | |||
| + | htmlspecialchars($content); | ||
| + | header('Content-Type: text/xml'); | ||
| + | print($content); | ||
| + | |||
| + | return; | ||
| + | |||
| + | } | ||
| + | |||
| + | mkRSS(); | ||
| + | |||
| + | ?> | ||
| + | </code> | ||
| + | // | ||
| + | // | ||
| + | ==== V1.4 ==== | ||
| + | Diese Version speichert eine Datei im jeweils angegebenen Order ab. Generierung kann bspw. durch einbettung in die index.php erreicht werden. | ||
| + | Einstellungen müßen im GESAMTEN script vorgenommen werden. | ||
| + | |||
| + | <code php|h news_rss.php V1.4 - Generierung in Ordner:|h> | ||
| <? | <? | ||
| function mkRSS () { | function mkRSS () { | ||