Witam.
Mam pewną prośbę. Czy ktoś obeznany może zajrzeć do mojego kodu archiwum, opartego na cutenewsie i podpowiedzieć w jaki sposób zmienić go tak, aby pokazywał wiadomości w kolejności czasowej? Chodzi o to, że obecnie pokazuje je pod względem ilości newsów, wygląda to tak:
Październik - 2013 (64)
Listopad - 2013 (60)
Wrzesień - 2013 (14)
Powinno być tak:
Listopad - 2013 (60)
Październik - 2013 (64)
Wrzesień - 2013 (14)
Oto kod archiwum:
<?PHP
$cutepath = __FILE__;
$cutepath = preg_replace( "'\\\show_archives\.php'", "", $cutepath); $cutepath = preg_replace( "'/show_archives\.php'", "", $cutepath);
require_once("$cutepath/inc/functions.inc.php");
require_once("$cutepath/data/config.php");
if(!isset($template) or
$template == "" or
strtolower($template) == "arch"){ require_once("$cutepath/data/Arch.tpl"); } else{
if(file_exists("$cutepath/data/${template}.tpl")){ require_once("$cutepath/data/${template}.tpl"); }
else{ die("Error!<br>the template <b>".htmlspecialchars($template)."</b> does not exists, note that templates are case sensetive and you must write the name exactly as it is"); } }
// Prepare requested categories
if(eregi("[a-z]", $category)){ die("<b>Error</b>!<br>CuteNews has detected that you use \$category = \"".htmlspecialchars($category)."\"; but you can call the categories only with their <b>ID</b> numbers and not with names<br> example:<br><blockquote><?PHP<br>\$category = \"1\";<br>include(\"path/to/show_archives.php\");<br>?></blockquote>");
}
$tmp_cats_arr = explode(",", $category); foreach($tmp_cats_arr as $key=>$value){
if($value != ""){ $requested_cats[$value] = TRUE; }
}
if($archive == "" or !$archive){
$news_file = "$cutepath/data/news.txt";
$comm_file = "$cutepath/data/comments.txt";
}else{
$news_file = "$cutepath/data/archives/$archive.news.arch";
$comm_file = "$cutepath/data/archives/$archive.comments.arch";
}
if($subaction == "" or
!isset($subaction)){ $user_query = cute_query_string
($QUERY_STRING, array("start_from", "archive", "subaction", "id", "ucat"));
if(!$handle = opendir("$cutepath/data/archives")){ die("<center>Can not open directory $cutepath/data/archives "); } while (false !== ($file = readdir($handle))) { if($file != "." and $file != ".." and $file_arr[1] == "news"){
$arch_arr[] = $file_arr[0];
}
}
function datePl($format,$time=NULL)
{
if($time===NULL)
'Jan'=>'Styczeń',
'Feb'=>'Luty',
'Mar'=>'Marzec',
'Apr'=>'Kwiecień',
'May'=>'Maj',
'Jun'=>'Czerwiec',
'Jul'=>'Lipiec',
'Aug'=>'Sierpień',
'Sep'=>'Wrzesień',
'Oct'=>'Październik',
'Nov'=>'Listopad',
'Dec'=>'Grudzień' );
}
foreach($arch_arr as $arch_file){
$news_lines = file("$cutepath/data/archives/$arch_file.news.arch"); $count = count($news_lines); $last = $count-1;
$first_news_arr = explode("|", $news_lines[$last]); $last_news_arr = explode("|", $news_lines[0
]);
$first_timestamp = $first_news_arr[0];
$last_timestamp = $last_news_arr[0];
echo"<a href=\"$PHP_SELF?archive=$arch_file&subaction=list-archive&$user_query\">". datePl
("M - <b>Y</b>",$last_timestamp)." <i>($count)</i></a><br /> ";
}
}
}
else{
if( $CN_HALT != TRUE and
$static != TRUE and
($subaction == "showcomments" or
$subaction == "showfull" or
$subaction == "addcomment") and
((!isset($category) or
$category == "") or
$requested_cats[$ucat] == TRUE) ){ if($subaction == "addcomment"){ $allow_add_comment = TRUE; $allow_comments = TRUE; }
if($subaction == "showcomments") $allow_comments = TRUE;
if(($subaction == "showcomments" or $allow_comments == TRUE) and $config_show_full_with_comments == "yes") $allow_full_story = TRUE;
if($subaction == "showfull") $allow_full_story = TRUE;
if($subaction == "showfull" and $config_show_comments_with_full == "yes") $allow_comments = TRUE;
}
else{
if($config_reverse_active == "yes"){ $reverse = TRUE; }
$allow_active_news = TRUE;
}
require("$cutepath/inc/shows.inc.php");
}
unset($template, $requested_cats, $reverse, $in_use, $archive, $archives_arr, $number, $no_prev, $no_next, $i, $showed, $prev, $used_archives); ?>
Z góry bardzo, ale to bardzo dziękuję za pomoc
Pozdrawiam
Problem udało mi się zażegnać
Jak ktoś by potrzebował pomocy, to tutaj jest rozwiązanie: http://cutephp.com/forum/index.php?showtopic=32552Za kolor przepraszam, ale chciałem, żeby było widoczne, iż problem już nieaktualny
Ten post edytował jin999 4.12.2013, 20:06:19