RSS Import - Problem mit Umlauten und Sonderzeichen

fullmonty
Beiträge: 11
Registriert: So 19. Feb 2006, 21:55
Wohnort: Schweiz
Kontaktdaten:

Beitrag von fullmonty »

Schön, wenns bei Dir hinhaut... Ich gönns Dir wirklich, nur mir würd' ichs mir noch viel mehr gönnen.
Habs versucht, klappt nicht. Sorry. Hier der Code zum Check.

Code: Alles auswählen

<?php
/***********************************************
* CONTENIDO MODUL - OUTPUT
*
* Modulname   :     Insert RSS feed
* Authors:     :       Timo Hummel, Andreas Lindner
* Copyright   :     Contenido - four for business
* Created     :     30.09.2005
************************************************/

cInclude("pear", "XML/Parser.php");
cInclude("pear", "XML/RSS.php");

if ("CMS_VALUE[0]" == "")
{
  $sFeed = "http://www.contenido.org/rss/de/news";
} else {
  $sFeed = "CMS_VALUE[0]";
}

if ("CMS_VALUE[2]" == "")
{
  $FeedMaxItems = 999;
} else {
   $FeedMaxItems = intval("CMS_VALUE[2]");
}

/* Preparse feed for an encoding due to the poorly designed
   PHP XML parser */
$sFeedContent = substr(@file_get_contents($sFeed),0,1024);
$sFeedContent = utf8_decode($sFeedContent);

$regExp = "/<\?xml.*encoding=[\"\'][\"\']\?>/i";
     
preg_match($regExp,trim($sFeedContent),$matches);

if ($matches[1])
{
  $rss =& new XML_RSS($sFeed, $matches[1]);
} else {
  $rss =& new XML_RSS($sFeed);
}

$rss->parse();

$tpl = new Template;

$i = 0;
foreach ($rss->getItems() as $item)
{
   if ($i < $FeedMaxItems) {
             
$tpl->set("d", "TITLE", htmlentities($item['title'],ENT_QUOTES));
$tpl->set("d", "LINK", htmlentities($item['link'],ENT_QUOTES));
$tpl->set("d", "DESCRIPTION", utf8_decode(htmlentities($item['description'],ENT_QUOTES)));        
       $tpl->set("d", "READ_ON", mi18n("weiterlesen"));
       $tpl->next();
   }
   $i++;
}

$tpl->generate($cfgClient[$client]["path"]["frontend"]."templates/"."CMS_VALUE[1]");
?>
Kannst Du mir Deinen Code posten?
THX
R.
rezeptionist
Beiträge: 1536
Registriert: Fr 20. Aug 2004, 10:07
Kontaktdaten:

Beitrag von rezeptionist »

ok ich meinte deinen Original mit dem Umbau am Title

aber hier

Code: Alles auswählen

<?php
/***********************************************
* CONTENIDO MODUL - OUTPUT
*
* Modulname   :     Insert RSS feed
* Authors:     :       Timo Hummel, Andreas Lindner
* Copyright   :     Contenido - four for business
* Created     :     30.09.2005
************************************************/

cInclude("pear", "XML/Parser.php");
cInclude("pear", "XML/RSS.php");

if ("CMS_VALUE[0]" == "")
{
  $sFeed = "http://www.contenido.org/rss/de/news";
} else {
  $sFeed = "CMS_VALUE[0]";
}

if ("CMS_VALUE[2]" == "")
{
  $FeedMaxItems = 999;
} else {
   $FeedMaxItems = intval("CMS_VALUE[2]");
}

/* Preparse feed for an encoding due to the poorly designed
   PHP XML parser */
$sFeedContent = substr(@file_get_contents($sFeed),0,1024);
$sFeedContent = utf8_decode($sFeedContent);
$regExp = "/<\?xml.*encoding=[\"\'][\"\']\?>/i";      
preg_match($regExp,trim($sFeedContent),$matches);

if ($matches[1])
{
  $rss =& new XML_RSS($sFeed, $matches[1]);
} else {
  $rss =& new XML_RSS($sFeed);
}

$rss->parse();

$tpl = new Template;

$i = 0;
foreach ($rss->getItems() as $item)
{
   if ($i < $FeedMaxItems) {
       $tpl->set("d", "TITLE",$item['title']);
       $tpl->set("d", "LINK",htmlentities($item['link'],ENT_QUOTES));
       $tpl->set("d", "DESCRIPTION", utf8_decode(htmlentities($item['description'],ENT_QUOTES)));
       $tpl->set("d", "READ_ON", mi18n("weiterlesen"));
       $tpl->next();
   }
   $i++;
}

$tpl->generate($cfgClient[$client]["path"]["frontend"]."templates/"."CMS_VALUE[1]");
?>
greets
fullmonty
Beiträge: 11
Registriert: So 19. Feb 2006, 21:55
Wohnort: Schweiz
Kontaktdaten:

Beitrag von fullmonty »

Alles klar. Habs eingebaut.

Wenn ich die Seite lade, keine Änderung. Leider...
Aber, wenn ich das Charakter-Encoding auf Unicode UTF-8 wechsle, dann hauts hin!!!

Also, hab den Code wie folgt noch angepasst:

Code: Alles auswählen

<?php
/***********************************************
* CONTENIDO MODUL - OUTPUT
*
* Modulname   :     Insert RSS feed
* Authors:     :       Timo Hummel, Andreas Lindner
* Copyright   :     Contenido - four for business
* Created     :     30.09.2005
************************************************/

cInclude("pear", "XML/Parser.php");
cInclude("pear", "XML/RSS.php");

if ("CMS_VALUE[0]" == "")
{
  $sFeed = "http://www.contenido.org/rss/de/news";
} else {
  $sFeed = "CMS_VALUE[0]";
}

if ("CMS_VALUE[2]" == "")
{
  $FeedMaxItems = 999;
} else {
   $FeedMaxItems = intval("CMS_VALUE[2]");
}

/* Preparse feed for an encoding due to the poorly designed
   PHP XML parser */
$sFeedContent = substr(@file_get_contents($sFeed),0,1024);
$sFeedContent = utf8_decode($sFeedContent);
 
$regExp = "/<\?xml.*encoding=[\"\'][\"\']\?>/i";    

preg_match($regExp,trim($sFeedContent),$matches);

if ($matches[1])
{
  $rss =& new XML_RSS($sFeed, $matches[1]);
} else {
  $rss =& new XML_RSS($sFeed);
}

$rss->parse();

$tpl = new Template;

$i = 0;
foreach ($rss->getItems() as $item)
{
   if ($i < $FeedMaxItems) {
       $tpl->set("d", "TITLE",utf8_decode($item['title']));
       $tpl->set("d", "LINK",htmlentities($item['link'],ENT_QUOTES));
       $tpl->set("d", "DESCRIPTION", utf8_decode(htmlentities($item['description'],ENT_QUOTES)));
       $tpl->set("d", "READ_ON", mi18n("weiterlesen"));
       $tpl->next();
   }
   $i++;
}

$tpl->generate($cfgClient[$client]["path"]["frontend"]."templates/"."CMS_VALUE[1]");
?>
Hey, herzlichen Dank, bist für heute mein Held!
Cheers und bis zum nächsten Mal.
R.
rezeptionist
Beiträge: 1536
Registriert: Fr 20. Aug 2004, 10:07
Kontaktdaten:

Beitrag von rezeptionist »

ups hatte schon gesucht , aber freut mich wenn es klappt. :wink:
greets
Gesperrt