Closed skerbis closed 1 year ago
Aus einem meiner Projekte ... Ausbaufähig Anpassbar.
<?php rex_response::cleanOutputBuffers(); rex_response::sendContentType('application/xml; charset=utf-8'); // Url zum Feed $base='https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; // Document Header definieren $xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom"></rss>'); // Channel.Deklaration $channel = $xml->addChild("channel"); $xml->addAttribute('version', '2.0'); $atom = $xml->channel->addChild('atom:atom:link'); //atom node $atom->addAttribute('href', $base); // atom node attribut $atom->addAttribute('rel', 'self'); $atom->addAttribute('type', 'application/rss+xml'); // Seitentitel $channel->addChild("title", "News Name"); // URL der Website $channel->addChild("link", "https://domain.TLD"); $channel->addChild("description", "NEWS von Name"); $channel->addChild("language", "de-de"); $channel->addChild('generator', 'REDAXO rss'); // generator node $children = rex_yform_manager_table::get('news') ->query() ->whereRaw('date <= NOW() AND not(timer_status = "1" AND date_online < CURRENT_DATE()) AND status = "1"') ->orderBy('date', 'DESC') ->limit(300) ->find(); $newsArticleId = 7; foreach ($children as $child) { $date = $url = ''; $url = 'https://domain.tld'.rex_getUrl($newsArticleId, '', ['id' => $child->id]); //Nur wenn Artikel online $item = $channel->addChild("item"); // Titel des Artikels auslesen $item->addChild("title", rex_escape($child->title)); $item->addChild("description", rex_escape($child->teaser)); // Link des Artikels generieren $item->addChild("link", $url); $item->addChild("guid", $url); $date = $child->date; // Datum und Uhrezeit des Postings $rssdate = $date; $item->addChild('pubDate', $rssdate); } // Ausgabe des RSS-Feeds echo $xml->asXML(); die();
duplicate #5 da geht's weiter...
Aus einem meiner Projekte ... Ausbaufähig Anpassbar.