Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 11
  1. #1
    Utente di HTML.it L'avatar di lukezz
    Registrato dal
    Feb 2010
    Messaggi
    494

    Visualizzare news più recente.

    Buonasera,
    Uso cutenews per pubblicare notizi nel mio sito.
    Ora mi chiedevo come faccio a visualizzare le 3 o 4 news più recenti in un altra pagina?

    Un pò di tempo fà avevo messo in un altro sito un codice per visualizzare gli ultimi post d un forum ma sicuramente sarà differente visto che cutenews nn necessita di database.
    Posto ugualmente il codice:
    Codice PHP:
    <?php
    $host 
    "localhost";
    $user "user";
    $pass "pass";
    $database "dabasename";
    $ultimi_post "7";


    $connessione mysql_connect($host$user$pass) or die("Non riesco a connettermi al DB");
    mysql_select_db($database$connessione) or die("Non riesco a selezionare il database");
    $query "SELECT tid,title,starter_id,starter_name FROM ibf_topics ORDER BY last_post DESC LIMIT 0,".$ultimi_post;



    $risultato mysql_query($query);
    while (
    $riga mysql_fetch_assoc($risultato)){

    if (
    strlen($riga['title'])>=6) {
    $riga['title']= substr($riga['title'],0,5)."..";

    }
    echo 
    "<font face=\"verdana\" size=\"-2\">x <a href=\"forum/index.php?showtopic={$riga['tid']}\" target=\"_top\">{$riga['title']}</a></font> <font face=\"verdana\" size=\"-2\">di [i]{$riga['starter_name']}[/i]</font>
    \n"
    ;
    }
    mysql_free_result($risultato);
    mysql_close($connessione);
    ?>

  2. #2
    Non conosco cutenews ma credo che con un LIMIT 3 te la cavi...
    Codice PHP:
    $query "SELECT tid,title,starter_id,starter_name FROM ibf_topics ORDER BY last_post DESC LIMIT 3".$ultimi_post
    Ce l'ho fatta! - ItalianPixel -

  3. #3
    Utente di HTML.it L'avatar di lukezz
    Registrato dal
    Feb 2010
    Messaggi
    494
    metto il codice direttamente nella pagina che voglio, o lo metto con un include?

  4. #4
    Prova a modificare la pagina che hai postato.
    Modifica, come ti ho scritto prima, la riga dove c'è la query $query, cambiando il LIMIT da
    LIMIT 0,
    a
    LIMIT 3
    Ce l'ho fatta! - ItalianPixel -

  5. #5
    Utente di HTML.it L'avatar di lukezz
    Registrato dal
    Feb 2010
    Messaggi
    494
    si ma cutenews non necessita di db quindi quella pagina che ho postato non va..

  6. #6
    In teoria dovrebbe trattare i dati in arrivo con query simili a quelle di mysql.
    Chiaro che mysql_query non funziona ma di sicuro c'è un sotterfugio.
    I file di cutenews per la "connessione" ai file come sono?
    Ce l'ho fatta! - ItalianPixel -

  7. #7
    Utente di HTML.it L'avatar di lukezz
    Registrato dal
    Feb 2010
    Messaggi
    494
    file.db.php

  8. #8
    Utente di HTML.it L'avatar di lukezz
    Registrato dal
    Feb 2010
    Messaggi
    494
    allora, il file che includo io nella mia pagina dove ci sono tutte le news e show_news.php che richiede il file news.txt dove vi sono tutte le news, io in un altra pagina devo visualizzare la news più recente.

    Ecco il file show_news.php:

    Codice PHP:
    <?PHP

    error_reporting 
    (E_ALL E_NOTICE);

    $cutepath =  __FILE__;
    $cutepath preg_replace"'\\\show_news\.php'"""$cutepath);
    $cutepath preg_replace"'/show_news\.php'"""$cutepath);

    require_once(
    "$cutepath/inc/functions.inc.php");
    require_once(
    "$cutepath/data/config.php");

    // If we are showing RSS, include some need variables.
    if($template == 'rss'){
       include(
    "$cutepath/data/rss_config.php");
    }

    //----------------------------------
    // Check if we are included by PATH
    //----------------------------------
    if($HTTP_SERVER_VARS["HTTP_ACCEPT"] or $HTTP_SERVER_VARS["HTTP_ACCEPT_CHARSET"] or $HTTP_SERVER_VARS["HTTP_ACCEPT_ENCODING"] or $HTTP_SERVER_VARS["HTTP_CONNECTION"]){ /* do nothing */ }
    elseif(
    eregi("show_news.php"$PHP_SELF)){
    die(
    "<h4>CuteNews has detected that you are including show_news.php using the URL to this file.

    This is incorrect and you must include it using the PATH to show_news.php</h4>
    Example:

    this is <font color=red>WRONG</font> : &lt;?PHP include(\"http://yoursite.com/cutenews/show_news.php\"); ?&gt;

    this is <font color=green>CORRECT</font>: &lt;?PHP include(\"cutenews/show_news.php\"); ?&gt;



    // <font size=2>if you think this message shouldn't be shown, open show_news.php and delete it from there</font>"
    );
    }
    //----------------------------------
    // End of the check
    //----------------------------------

    if(!isset($subaction) or $subaction == ""){ $subaction $POST["subaction"]; }

    if(!isset(
    $template) or $template == "" or strtolower($template) == "default"){ require_once("$cutepath/data/Default.tpl"); }
    else{
            if(
    file_exists("$cutepath/data/${template}.tpl")){ require("$cutepath/data/${template}.tpl"); }
        else{ die(
    "Error!
    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]!
    CuteNews has detected that you use \$category = \"
    $category\"; but you can call the categories only with their [b]ID[/b] numbers and not with names

        example:
    <blockquote>&lt;?PHP
    \$category = \"1\";
    include(\"path/to/show_news.php\");
    ?&gt;</blockquote>"
    );
    }
    $category preg_replace("/ /"""$category);
    $tmp_cats_arr explode(","$category);
    foreach(
    $tmp_cats_arr as $key=>$value){
        if(
    $value != ""){ $requested_cats[$value] = TRUE; }
    }

    if(
    $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";
    }

    $allow_add_comment                        FALSE;
    $allow_full_story                        FALSE;
    $allow_active_news                         FALSE;
    $allow_comments                         FALSE;



    //<<<------------ Detarime what user want to do
    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;
    }
    //----------->>> Detarime what user want to do

    require("$cutepath/inc/shows.inc.php");
        if(
    $_GET['archive'] and $_GET['archive'] != ''){ $archive $_GET['archive']; } // stupid fix ?
    unset($static$template$requested_cats$category$catid$cat,$reverse$in_use$archives_arr$number$no_prev$no_next$i$showed$prev$used_archives);
    ?>

  9. #9
    Copiato dal sito di cutenews:
    when showing news, archives you can use $number = x; to limit the to x the number of maximum showed news on one page. If you use $number, "next >>" link to remaining news will be displayed._

    if you want to show news, archives from certain category you can use $category = "ID"; where ID is the id of the category, you can choose and more that one category like this: $category = "ID1,ID2,ID3";

    when you want to display news and headlines on one page for example, and want when a headline is clicked, the article to be displayed on the place of the news you must use $static = TRUE; before including headlines.
    Link di riferimento
    Ce l'ho fatta! - ItalianPixel -

  10. #10
    Utente di HTML.it L'avatar di lukezz
    Registrato dal
    Feb 2010
    Messaggi
    494
    allora nell'include ho messo $number="1" però sotto mi mette pagina 1 2 3 con le altre news, io voglio solo visulizzare la prima news e la visualizza ma senza vedere le altre, come faccio?

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.