Ich habe ein kleines Problem mit folgendem Script, momentan stellt es News anhand des Datums/der Ordnernamen sortiert dar. Ich wünsche mir aber eine Random-Darstellung, die Reihenfolge und Sortierung sollte immer variieren. Wie kann ich sowas bewerkstelligen, jemand eine Idee?
PHP-Code:
<?php
/*
*/
function newsindex($news_count = false) {
global $NW_RUNTIME, $NWCONF_SYSTEM, $NWCONF_INDEX, $NW_TRANSLATION;
if (!$news_count)
$news_count = $NWCONF_INDEX['article_newscount'];
$dirlist = get_filelist ($NWCONF_SYSTEM['server_path'].$NWCONF_SYSTEM['news_dir']);
$content = false;
if ($dirlist) {
$admore = true;
for ($i = 0; $admore == true && $dirlist[$i]; $i++) {
$adfiles = get_filelist($dirlist[$i]);
for($j = 0; sizeof($file_data) < $news_count && $adfiles[$j]; $j++) {
$file_entries = get_filedata($adfiles[$j]);
if ($file_entries['TOPIC'] == $NW_RUNTIME['showtopic'] || $NW_RUNTIME['showtopic'] == 'all' || !$NW_RUNTIME['showtopic']) {
if ((!$file_entries['EXPIRE'] || $file_entries['EXPIRE'] >= $NW_RUNTIME['act_timestamp']) && (!$file_entries['STARTDATE'] || $file_entries['STARTDATE'] <= $NW_RUNTIME['act_timestamp']))
$file_data[] = $file_entries;
}
}
if (sizeof($file_data) >= $news_count)
$admore = false;
}
}
if ($file_data) {
if (@is_file($NWCONF_SYSTEM['server_path'].$NWCONF_SYSTEM['template_dir'].$NW_RUNTIME['showtopic'].'/newsindex.tpl'))
$tpl_index = file($NWCONF_SYSTEM['server_path'].$NWCONF_SYSTEM['template_dir'].$NW_RUNTIME['showtopic'].'/newsindex.tpl');
else
$tpl_index = file($NWCONF_SYSTEM['server_path'].$NWCONF_SYSTEM['template_dir'].'default/newsindex.tpl');
while(list($key,$file_entries) = each($file_data)) {
$filename = basename($file_entries['FILENAME']);
if ($file_entries['ARTICLE']) {
$url = $NWCONF_SYSTEM['domain_path'].'article'.$NWCONF_SYSTEM['php_ext'].'?article_file='.$file_entries['ARTICLE'];
}
else {
$url_date = strftime('%Y%m', $filename);
$url = $NWCONF_SYSTEM['domain_path'].$NWCONF_SYSTEM['index_file'].'?nwaction=shownews&nwmode=archiv&newsmonth='.$url_date.'#'.$filename;
}
$url = '<a href="'.$url.'" target="'.$NWCONF_INDEX['link_target'].'">'.$file_entries['TITLE'].'</a>';
if ($NWCONF_INDEX['index_showdate'])
$news_date = strftime($NWCONF_INDEX['index_datefmt'], $filename).' ';
else
$news_date = false;
while(list($k,$line) = each($tpl_index)) {
$line = str_replace('[--DATE--]',$news_date,$line);
$line = str_replace('[--TITLE--]',$url,$line);
$line = str_replace('[--TOPIC--]',$file_entries['TOPIC'],$line);
echo $line;
}
reset($tpl_index);
$content = true;
}
}
if (!$content)
echo $NW_TRANSLATION['noposts_newsindex'];
}
?>
Kommentar