vorrei un Limite di News in Home
-
Risolto il problema della configurazione del Pannello (vi ringrazio per i vostri consigli) ,mi serivirebbe sapere come posso impostare un limite al numero di news che devono apparire in primo piano nella mia Home Page (ad esempio 3)..
Il Pannello che uso per le news è Article Manager (scaricabile)..
Quello sottostante è il codice del file config.php
<? $summary_template = "t_summary.html"; $article_template = "t_article.html"; $max_summary = 5; $max_latest = 5; $password = "test"; ?>Quest altro è il file del pannello news.php
<? [B]include ("template.inc");[/B] [B]include ("[/B][COLOR=blue]config.php[/COLOR][B]");[/B] [B]$summary_template = "t_summary.html";[/B] [B]$article_template = "t_article.html";[/B] [B][COLOR=blue]$max_summary = 5;[/COLOR][/B] function summary_page ($subject, $date, $summary, $article_id) { global $summary_template; $t = new Template(); $t->set_file("SummaryPage", $summary_template); $article_url = "article_".$article_id.".html"; $date = nl2br($date); $summary = nl2br($summary); $t->set_var( array( "subject" => $subject, "date" => $date, "summary" => $summary, "article_url" => $article_url )); [B]$t->parse("Summary", "SummaryPage");[/B] [B]return $t->get_var("Summary");[/B] } function main_page ($subject, $date, $summary, $article_id, $body) { global $article_template; $t = new Template(); $t->set_file("ArticlePage", $article_template); $article_url = "article_".$article_id.".html"; $date = nl2br($date); $summary = nl2br($summary); $body = nl2br($body); $t->set_var( array( "subject" => $subject, "date" => $date, "summary" => $summary, "body" => $body, "article_url" => $article_url )); [B]$t->parse("Article", "ArticlePage");[/B] [B]return $t->get_var("Article"); [/B] [B]}[/B] [B]function add_article($filename, $news)[/B] [B]{[/B] [B]if(file_exists($filename)){[/B] [B]$fh = fopen($filename, "r");[/B] [B]$old_news = fread($fh, filesize($filename));[/B] [B]fclose($fh); [/B] [B]}[/B] [B]/* TODO: Multipage articles[/B] [B][COLOR=blue]preg_match_all("<!--ARTICLE PAGE=(\d*)-->", $old_news, $matches;[/COLOR][/B] [B][COLOR=blue]if( count($matches[0]) >= $max_summary){[/COLOR][/B] [B][COLOR=blue]$oldfilename = $filename.($matches[0][0]+1);[/COLOR][/B] [B][COLOR=blue]} [/COLOR][/B] [B][COLOR=blue]*/[/COLOR][/B] [B][COLOR=blue]$fh = fopen($filename, "w");[/COLOR][/B] [B][COLOR=blue]$news = stripslashes($news);[/COLOR][/B] [B][COLOR=blue]fwrite($fh, "\n<!--ARTICLE-->\n$news $old_news");[/COLOR][/B] [B][COLOR=blue]fclose($fh);[/COLOR][/B] [B]}[/B] [B]?>[/B] <? if(strcmp($subject, "")){ if(!(strcmp($passwd, $password))){ add_article("article_summary.html", summary_page($subject, $date, $summary, $article_id)); add_article("article_$article_id.html", main_page($subject, $date, $summary, $article_id, $body)); echo "<p> Article has been added! <p>"; }else{ echo "<p><b> Password is wrong! </b>"; } } ?>Questo il codice del file latest.php
[SIZE=2]<?[/SIZE] [SIZE=2]require([COLOR=blue]'config.php'[/COLOR]); [/SIZE] [SIZE=2]$filename = "article_summary.html";[/SIZE] [SIZE=2]#- open article summaries[/SIZE] [SIZE=2]if(file_exists($filename)){[/SIZE] [SIZE=2]$fh = fopen($filename, "r");[/SIZE] [SIZE=2]$old_news = fread($fh, filesize($filename));[/SIZE] [SIZE=2]fclose($fh);[/SIZE] [SIZE=2]}[/SIZE] [SIZE=2][B][COLOR=blue]#- get first five article[/COLOR][/B][/SIZE] [SIZE=2][B][COLOR=blue]$articles = explode("<!--ARTICLE-->", $old_news);[/COLOR][/B][/SIZE] [SIZE=2][B][COLOR=blue]$i=0;[/COLOR][/B][/SIZE] [SIZE=2][B]foreach ( $articles as $article ){[/B][/SIZE] [SIZE=2][B]if(count($articles)>$i){[/B][/SIZE] [SIZE=2][B]if($max_latest >= $i++){[/B][/SIZE] [SIZE=2][B]print $article;[/B][/SIZE] [SIZE=2]}[/SIZE] [SIZE=2]}[/SIZE] [SIZE=2]}[/SIZE] [SIZE=2]?>[/SIZE]*Ho evidenziato,quelli che secondo me potrebbero essere passi da variare..
Ho già provato a cambiare qualche voce in precedenza,ma con nessun risultato..:(
Qualcuno puo dirmi come fare?Grazie,anticipatamente:)
Ciao! Sembra che tu sia interessato a questa conversazione, ma non hai ancora un account.
Stanco di dover scorrere gli stessi post a ogni visita? Quando registri un account, tornerai sempre esattamente dove eri rimasto e potrai scegliere di essere avvisato delle nuove risposte (tramite email o notifica push). Potrai anche salvare segnalibri e votare i post per mostrare il tuo apprezzamento agli altri membri della comunità.
Con il tuo contributo, questo post potrebbe essere ancora migliore 💗
Registrati Accedi