Hallo zusammen
Ich benutze diesen Newsticker. Er stellt aber komischerweise die ältesten Nachrichten zuerst dar. Nach einem Email mit dem Programmierer hat er mir einen Hack dazu geschickt, wollte den euch nicht vorenthalten (nach Rücksprache mit dem Programmierer):
Man muss per Typo-Code das hier eintragen:
plugin.tx_datamintsnewsticker_pi1{
newsItemOrderBy = datetime DESC
}
Und dann muss man die class.tx_datamintsnewsticker_pi1.php erneuern mit diesem Code:
<?php
/***************************************************************
* Copyright notice
*
* (c) 2005 Dirk Maiwert (d.maiwert@datamints.com)
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Plugin 'datamints Newsticker' for the 'datamints_newsticker' extension.
*
* @author Dirk Maiwert <d.maiwert@datamints.com>
*/
require_once(PATH_tslib.'class.tslib_pibase.php');
class tx_datamintsnewsticker_pi1 extends tslib_pibase {
var $prefixId = 'tx_datamintsnewsticker_pi1'; // Same as class name
var $scriptRelPath = 'pi1/class.tx_datamintsnewsticker_pi1.php'; // Path to this script relative to the extension dir.
var $extKey = 'datamints_newsticker'; // The extension key.
var $pi_checkCHash = TRUE;
var $lang;
var $settingsPage;
var $ntSettings = array(); //Contains all Values from settings-table of chosen page
function main($content, $conf) {
$this->conf=$conf;
$this->pi_setPiVarDefaults();
$this->pi_loadLL();
//$GLOBALS['TSFE']->set_no_cache();
$this->local_cObj = t3lib_div::makeInstance("tslib_cObj");
//Show errors (uncomment in production)
$GLOBALS['TYPO3_DB']->debugOutput = TRUE;
//Set language inside class
$lang = t3lib_div::_GP('L');
if ($lang < 1) {
$lang = 0;
}
$this->lang = $lang;
//Prepare Typolink
$this->local_cObj->setCurrentVal($GLOBALS["TSFE"]->id);
$this->typolink_conf = $this->conf["typolink."];
$this->typolink_conf["parameter."]["current"] = 1;
$this->typolink_conf["additionalParams"] = $this->cObj->stdWrap($this->typolink_conf["additionalParams"], $this->typolink_conf["additionalParams."]);
unset($this->typolink_conf["additionalParams."]);
//Den Aufruf des JS in den Bodytag schreiben.
$GLOBALS['TSFE']->JSeventFuncCalls['onload'][$this->pObj->prefixId] = 'loadScroller();';
$content = $this->startTicker($conf);
//return $this->pi_wrapInBaseClass($content);
return $content; //Pure HTML to keep <script type="text/javascript"> tags.
}
function startTicker ($conf) {
//Hier beginnt die Implemtentierung
//Wenn im TS die Seite mit der config angegeben ist, wird die verwendet, ansonsten
//die aktuelle Seite
if ($conf['settingsPage']) {
$this->settingsPage = $conf['settingsPage'];
}
else {
//Die aktuelle Seite
$this->settingsPage = $GLOBALS['TSFE']->id;
}
//echo $this->settingsPage;
//Zuerst mal die Einstellungen aus der Datenbank holen
//Den Datensatz, der zur aktuellen Seite gehört
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'*',
'tx_datamintsnewsticker_settings',
'pid="' . $this->settingsPage . '"',
'',
''); //Order by
$this->ntSettings = array();
$this->ntSettings = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); //Always one line
//t3lib_div::debug($GLOBALS['TYPO3_DB']);
$GLOBALS['TYPO3_DB'] -> sql_free_result($res);
//Artikel holen und Script aufbauen
$lokContent = $this->buildJs($this->ntSettings['uid']);
return $lokContent;
}
function setSettingsJs () {
//Writes Settings from Table into JS into page header
//All settings have default values.
$settingsJs = '';
if ($this->ntSettings['orientation'] == '1'){
$settingsJs .= 'orientation = "horizontal";'; // Orientation of scroller (Horizontal or vertical)
}
else {
$settingsJs .= 'orientation = "vertical";';
}
if ($this->ntSettings['t_width'] > 10){
$settingsJs .= 'objScrollWidth = "' . $this->ntSettings['t_width'] . '";'; // Width of entire scroller.
}
else {
$settingsJs .= 'objScrollWidth = "250";';
}
if ($this->ntSettings['t_height'] > 5){
$settingsJs .= 'objScrollHeight = "' . $this->ntSettings['t_height'] . '";'; // Height of Scroller.
}
else {
$settingsJs .= 'objScrollHeight = "20";';
}
if ($this->ntSettings['border_width']){
$settingsJs .= 'borderWidth = "' . $this->ntSettings['border_width'] . '";'; // Width of border. (use 0 for no border).
}
else {
$settingsJs .= 'borderWidth = "0";';
}
if ($this->ntSettings['border_color']){
$settingsJs .= 'borderColour = "' . $this->ntSettings['border_color'] . '";'; // Colour of scroller border. (Use either hexadecimal or text values. e.g. "#FF0000" or "Red")
}
else {
$settingsJs .= 'borderColour = "#999999";';
}
if ($this->ntSettings['bg_color']){
$settingsJs .= 'backColour = "' . $this->ntSettings['bg_color'] . '";'; // Colour of scroller background. (Use either hexadecimal or text values. e.g. "#FF0000" or "Red")
}
else {
$settingsJs .= 'backColour = "#f4f4f4";';
}
if ($this->ntSettings['text_align']){
$settingsJs .= 'textAlignment = "' . $this->ntSettings['text_align'] . '";'; // Alignment of each scroller item. Only really makes a difference on vertical scroller (center, left, right, justify)
}
else {
$settingsJs .= 'textAlignment = "center";';
}
if ($this->ntSettings['classname_link']){
$settingsJs .= 'link_cssClass = "' . $this->ntSettings['classname_link'] . '";'; // CSS class for Links
}
else {
$settingsJs .= 'link_cssClass = "dmnt_a";';
}
if ($this->ntSettings['bg_image']){
$settingsJs .= 'bg_image = "' . $this->ntSettings['bg_image'] . '";'; // background image for scroller
}
else {
$settingsJs .= 'bg_image = "";';
}
if ($this->ntSettings['article_divider']){
$settingsJs .= 'objScrollDivider = "' . $this->ntSettings['article_divider'] . '";'; // background image for scroller
}
else {
$settingsJs .= 'objScrollDivider = "-";';
}
if ($this->ntSettings['speed']){
$settingsJs .= 'speed = "' . $this->ntSettings['speed'] . '";'; // background image for scroller
}
else {
$settingsJs .= 'speed = 75;';
}
if ($this->ntSettings['timeout']){
$settingsJs .= 'ticker_pause = "' . $this->ntSettings['timeout'] . '";'; // background image for scroller
}
else {
$settingsJs .= 'ticker_pause = 500;';
}
//Not set in Typo3, just to complete it.
$settingsJs .= 'stopScroll = 1;'; // Pause the scroller on mouseOver. (use 0 for no.)
$settingsJs .= 'staticColour = "#999999";'; // Colour of scroller items that are NOT a link. (including scrollerDivider characters)
return $settingsJs; //includes JS lines with variables
}
function buildJs ($idSetting) {
//Erstellt Javascript Newsticker aufgrund der übergebenen Informationen.
//Get content from News Table
$res = $this->getContentResult("tt_news");
//t3lib_div::debug($res);
//Artikelliste in Header laden
//Define new scroller elements here in the following format.
//Article[i] = new Array ("display text", "URL", "frame target to load link in")
$articleData = '<script language="javascript" type="text/javascript">
Article = new Array;';
$temp_conf = $this->typolink_conf;
//Get the news Items and put into JS-Array
$row = array();
$i = 0;
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
//Kategorien auflisten
$articleData .= 'Article[' . $i . '] = new Array ("' . str_replace('"', '\"', $row['title']) . '", "index.php?id=' . $this->ntSettings['news_id'] . '&tx_ttnews[tt_news]=' . $row['uid'] . '&no_cache=1' . $temp_conf['additionalParams'] . '", "_top");';
//echo $articleData;
$i++;
}
//Gleich noch die Settings mit in diesen Script-Block schreiben
$articleData .= $this->setSettingsJs();
$articleData .= '</script>';
$GLOBALS['TYPO3_DB'] -> sql_free_result($res);
//Javascript in Header laden
//Aufbereitete Artikeldaten in Header schreiben
$GLOBALS['TSFE']->additionalHeaderData[$this->pObj->prefixId] .= $articleData;
$GLOBALS['TSFE']->additionalHeaderData[$this->pObj->prefixId] .=
'<script language="javascript" type="text/javascript" src="' .
$GLOBALS['TSFE']-">absRefPrefix . t3lib_extMgm::siteRelPath('datamints_newsticker') .
'res/dm_scroller.js"></script>';
//Into the content area only the call to the sroller function is printed
return '<script type="text/javascript">buildScroller();</script>';
}
function getContentResult($table) {
global $TCA;
//Check if there are special catagories only to fetch:
if ($this->ntSettings['categories']){
//There are special categories configured. So we get them and append to From and Where clause
$addFrom = ',tt_news_cat_mm';
$arrCats = explode(',', $this->ntSettings['categories']);
$addWhere = ' AND uid=uid_local AND uid_foreign IN(';
$i = 0;
$comma = '';
foreach ($arrCats as $value) {
//To be more stable at strange inputs, first the string is exploded and set
//together to a valid IN-String. Everything which is not OK, is now inside the values.
if ($i > 0) {
//add comma if not first
$comma = ',';
}
$addWhere .= $comma . '"' . $value . '"';
$i++;
}
$addWhere .= ')'; //End IN-clause
}
else {
//All categories
$addFrom = '';
$addWhere = '';
}
if ($TCA[$table]) {
if ($this->conf['newsPidList'] == '') {
$news_select = ' 1=1';
}
else {
$news_select = ' WHERE pid IN (' . $this->conf['newsPidList'] . ')';
}
//Auf Sprache einschränken
if ($this->ntSettings['multilang'] == 1) {
//If this is a multilanguage Site the field sys_language_uid must (and CAN) be used
if ($this->lang == 0) {
//Bei deutsch kann es auch sein, daß im Feld -1 steht.
$news_select .= ' AND sys_language_uid IN("-1" ,"' . $this->lang . '")';
}
else {
$news_select .= ' AND sys_language_uid="' . $this->lang . '"';
}
}
//Add whereClause for categories
$news_select .= $addWhere;
if ($this->conf['newsItemOrderBy'] == '') {
$orderBy = '';
}
else {
$orderBy = $this->conf['newsItemOrderBy'];
}
if ($this->conf['newsItemCount'] == '') {
$limit = '';
}
else {
$limit = ' LIMIT 0,' . $this->conf['newsItemCount'];
}
//Limit to non-archived News?
if (!$this->ntSettings['archivedtoo']){
//If "Archived too" is not set the SQL is limited to newer News only.
$news_select .= ' AND (archivedate >= UNIX_TIMESTAMP() OR archivedate = 0)';
}
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'title, uid',
$table . $addFrom,
$news_select . $this->cObj->enableFields($table),
$limit,
$orderBy); //Order by
//echo $news_select;
//echo $GLOBALS['TYPO3_DB']->debug_lastBuiltQuery;
return $res;
}
}
}
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/datamints_newsticker/pi1/class.tx_datamintsnewsticker_pi1.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/datamints_newsticker/pi1/class.tx_datamintsnewsticker_pi1.php']);
}
?>
Bei mir hats funktioniert.