| |
|
|
|
| |
| Artikel »
Tutorials-1.6.5 »
TUTORIAL 1.6.5: Heise Newsticker
|
TUTORIAL 1.6.5: Heise Newsticker
23.03.2010 von KC-Cracky
Dokumentation: Nach Abschluss dieses Tutorials werden die News von "Heise.de" bei Ihnen auf der Seite angezeigt und gescrollt.
Sie können den Ticker so ausgeben lassen:
 | PHP-Code Anfang: (1 Zeile) | Code markieren | | <marquee scrollamount="2" scrolldelay="2">$out_buffer</marquee> |
| | | PHP-Code ENDE: (1 Zeile) | Code markieren |
|
|
Vorzugsweise in die pkinc/publictpl.site.htm schreiben oder unter ACP => Vorlagen => Site.htm
Wo Sie das integrieren ist Ihnen überlassen!
PS: Der Marquee Befehl ist allerdings nicht XHTML Konform und verursacht Fehler auf der Seite, wenn Sie Ihre Seite mit dem W3C Service validieren. Sie können alternativ auch ein Jquery-Javascript suchen und das damit sliden, somit würde der Code valide bleiben.
Nun öffne die pkinc/public.php und suche:
Füge darunter ein:
Die heise.php sollte so aussehen (kommt ins Verzeichnis pkinc/public):
 | PHP-Code Anfang: (48 Zeilen) | Code markieren | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
| <?php if(!defined('pkFRONTEND') || pkFRONTEND!='public') die('Direct access to this location is not permitted.'); /* Heise News Grabber 2.2 Copyright 2004 by MasterBootRecord.de - Matthias Zirngibl http://masterbootrecord.de/docs/heisenewsgrabber.php */ $ENABLE_CACHING = false; //Before you enable caching set the CACHE_FILE correctly... $CACHE_FILE = '/tmp/heisenews.rdf'; //Where to store the cache file. HAVE TO BE WRITEABLE FOR THE USER-ACCOUNT OF THE WEBSERVER //$CACHE_FILE = 'c://temp//heisenews.rdf'; //For Windows $CACHE_REFRESH_TIME = 20; //Cache timeout in minutes $MAX_NEWS = 100; //If you want to restrict the headlines you can do it here if ($ENABLE_CACHING){ $cache_diff =(time() - @filemtime($CACHE_FILE))/60; if (!file_exists($CACHE_FILE) or ($cache_diff > 20) ){ $fcontents = join ('', @file ('http://www.heise.de/newsticker/heise.rdf')); @unlink($CACHE_FILE); $handle = @fopen($CACHE_FILE, 'x+'); @fwrite($handle, $fcontents); @fclose($handle); } $fcontents = join ('', @file ($CACHE_FILE)); } else { $fcontents = join ('', @file ('http://www.heise.de/newsticker/heise.rdf')); } $fcontents = str_replace ("</item>", "", $fcontents); $fcontents = str_replace ("</link>", "", $fcontents); $splices = explode ("<item>", $fcontents); if (count($splices) > $MAX_NEWS){ $stop_at = $MAX_NEWS; } else { $stop_at = count($splices); } $out_buffer = '<span class="heisenews">'; for ($i = 1; $i < $stop_at; $i++){ $link = explode("<link>",$splices[$i]); $link[1] = strip_tags($link[1]); $headline = str_replace ("<title>", '<a href="' . trim($link[1]) . '" target="_blank" class="heiseheadline">', $splices[$i]); $headline = str_replace ("</title>", "</a>", $headline); $headline = explode ("<link>", $headline); $headline = $headline[0]; $out_buffer = $out_buffer . $headline . '<a href="http://masterbootrecord.de"><img src="1.gif" height="20" width="1" border="0" align="top" alt="" /></a> '; } $out_buffer = $out_buffer . "</span>"; ?>
|
| | | PHP-Code ENDE: (48 Zeilen) | Code markieren |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|