Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 12
  1. #1

    Puntini di sospensione...

    ciao a tutti.....averei un problema da risolvere...

    sto creando una pagina in php che mi visualizza gli ultimi post del forum utilizzando l'addon per vbulletin...vbexternal....tuttavia questa pagina deve essere visualizzata all'interno di un modulo di Mambo e succede che se il titolo del Topic supera la larghezza della colonna mi sfasa tutto il template del sito. Vi posto il file che usa l'addon...a me interessa visualizzare gli ultimi post ( vi posto la funzione interessata) qualcuno può dirmi cosa devo modificare e come? grazie mille!


    // ---------------------------------------------------
    // FUNCTION: output_NewestThreads
    // DETAIL: Outputs X newest threads ordered by
    // start date descending. $a
    // specifies amount to show (Default 5)
    // and $f can specify certain forums
    // to grab from (1,3,4), by default it pulls
    // from all forums.
    // ---------------------------------------------------

    function output_NewestThreads($a = 5,$f = ""){
    global $db, $Data;

    // Define amount to show
    $Amount = ($a)? intval($a) : 5;

    // Define Forum(s) To Pull From
    $Forums = ($f)? $f: '';
    $SQL = '';

    if($Forums){
    $SQL = " where forumid in({$Forums})";
    }

    // Load Template
    $Template = LoadTemplate("newest_threads.html");

    // Collect Data
    $NewestThreads = $db->query("select * from ".TABLE_PREFIX."thread{$SQL} order by dateline desc limit 0,$Amount");

    while($Thread = $db->fetch_array($NewestThreads)){
    $Data .= ParseTemplate($Template,
    array(
    'threadid' => $Thread['threadid'],
    'threadname' => $Thread['title'],
    'postuserid' => $Thread['postuserid'],
    'postusername' => $Thread['postusername'],
    'replies' => vb_number_format($Thread['replycount']),
    'views' => vb_number_format($Thread['views']),
    'lastposter' => $Thread['lastposter'],
    )
    );
    }

    doOutput();
    }

  2. #2
    Utente bannato L'avatar di Braco
    Registrato dal
    Oct 2005
    Messaggi
    1,697

    Re: Puntini di sospensione...

    Originariamente inviato da DarioVinci
    ciao a tutti.....averei un problema da risolvere...

    sto creando una pagina in php che mi visualizza gli ultimi post del forum utilizzando l'addon per vbulletin...vbexternal....tuttavia questa pagina deve essere visualizzata all'interno di un modulo di Mambo e succede che se il titolo del Topic supera la larghezza della colonna mi sfasa tutto il template del sito. Vi posto il file che usa l'addon...a me interessa visualizzare gli ultimi post ( vi posto la funzione interessata) qualcuno può dirmi cosa devo modificare e come? grazie mille!


    // ---------------------------------------------------
    // FUNCTION: output_NewestThreads
    // DETAIL: Outputs X newest threads ordered by
    // start date descending. $a
    // specifies amount to show (Default 5)
    // and $f can specify certain forums
    // to grab from (1,3,4), by default it pulls
    // from all forums.
    // ---------------------------------------------------

    function output_NewestThreads($a = 5,$f = ""){
    global $db, $Data;

    // Define amount to show
    $Amount = ($a)? intval($a) : 5;

    // Define Forum(s) To Pull From
    $Forums = ($f)? $f: '';
    $SQL = '';

    if($Forums){
    $SQL = " where forumid in({$Forums})";
    }

    // Load Template
    $Template = LoadTemplate("newest_threads.html");

    // Collect Data
    $NewestThreads = $db->query("select * from ".TABLE_PREFIX."thread{$SQL} order by dateline desc limit 0,$Amount");

    while($Thread = $db->fetch_array($NewestThreads)){
    $Data .= ParseTemplate($Template,
    array(
    'threadid' => $Thread['threadid'],
    'threadname' => $Thread['title'],
    'postuserid' => $Thread['postuserid'],
    'postusername' => $Thread['postusername'],
    'replies' => vb_number_format($Thread['replycount']),
    'views' => vb_number_format($Thread['views']),
    'lastposter' => $Thread['lastposter'],
    )
    );
    }

    doOutput();
    }
    Prova questo quì uso "email" ma lo puoi cambiare

    Codice PHP:
    //Dopo un tot di caratteri mette i 3 puntini
    $email $email
    if (
    strlen($email) >= 15){//Se la stringa è 15 caratteri o più(senza puntini), viene accorciata a 12+...
    $email=substr($email,0,12)."...";


  3. #3
    scusa, ma dove lo devo inserire? e poi la variabile $email la posso lasciare o deve essere cambiata?

  4. #4
    Utente bannato L'avatar di Braco
    Registrato dal
    Oct 2005
    Messaggi
    1,697
    Originariamente inviato da DarioVinci
    scusa, ma dove lo devo inserire? e poi la variabile $email la posso lasciare o deve essere cambiata?
    La devi cambiare ed inserire il tuo item, es:

    Codice PHP:
    //Dopo un tot di caratteri mette i 3 puntini 
    $threadname $Thread
    if (
    strlen($threadname) >= 15){//Se la stringa è 15 caratteri o più(senza puntini), viene accorciata a 12+... 
    $Thread=substr($threadname,0,12)."..."


  5. #5
    ho provato come mi hai detto....solo ce siccome la variabile $Thread è inserita in un array nn mi stampa la variabile $threadname

  6. #6
    Utente bannato L'avatar di Braco
    Registrato dal
    Oct 2005
    Messaggi
    1,697
    Originariamente inviato da DarioVinci
    ho provato come mi hai detto....solo ce siccome la variabile $Thread è inserita in un array nn mi stampa la variabile $threadname
    Toglila dall'array

  7. #7
    ma se la tolgo dall'array nn mi prende i dati dal db.....nn ci sto capendo + niente

  8. #8
    Utente bannato L'avatar di Braco
    Registrato dal
    Oct 2005
    Messaggi
    1,697
    Originariamente inviato da DarioVinci
    ma se la tolgo dall'array nn mi prende i dati dal db.....nn ci sto capendo + niente
    Lo scopo è che il titolo del topic non vada oltre un tot numero di caratteri perciò quel codice che ti ho dato serve per mettere a video un tot numero di caratteri e va messo nella pag. che mette a video i dati, serve solo a quello.

  9. #9
    Codice PHP:
    //*======================================================================*\
    || #################################################################### ||
    || # vBExternal v1.6 By Zero Tolerance [[url]http://gzevolution.net[/url]]        ||
    || # This file may not be redistributed, copied in whole or part    ||
    || # without written permission.                    ||
    || # Copyright (C) 2005 Inferno Technologies.                ||
    || #################################################################### ||
    \*======================================================================*/

    // ---------------------------------------------------
    // Start Set PHP Environment
    // ---------------------------------------------------

    error_reporting(E_ALL & ~E_NOTICE);

    // ---------------------------------------------------
    // End Set PHP Environment
    // ---------------------------------------------------

    // ---------------------------------------------------
    // Start Define Important Constants
    // ---------------------------------------------------

    define('NO_REGISTER_GLOBALS'1);
    define('THIS_SCRIPT''vBExternal');

    // ---------------------------------------------------
    // End Define Important Constants
    // ---------------------------------------------------

    // ---------------------------------------------------
    // Start Cache Of Any Needed Templates/Phrase's
    // ---------------------------------------------------

    $phrasegroups = array();

    $specialtemplates = array(
                    
    'options',
    );

    $actiontemplates = array();

    $globaltemplates = array();

    // ---------------------------------------------------
    // End Cache Of Any Needed Templates/Phrase's
    // ---------------------------------------------------

    // ---------------------------------------------------
    // Start Call DB & Establish Connection
    // ---------------------------------------------------

    if( !file_exists('./includes/config.php'))
    {
        echo 
    "includes/config.php does not exist. Cannot continue.";
        exit;
    }

    require_once(
    './includes/class_core.php');
    require(
    './includes/config.php');

    DEFINE('DIR','.');
    DEFINE('TABLE_PREFIX',$config['Database']['tableprefix']);

    $vbulletin =& new vB_Registry(); // Fake an OOP Object

    switch (strtolower($config['Database']['dbtype']))
    {
        
    // load standard MySQL class
        
    case 'mysql':
        case 
    '':
        {
            
    $db =& new vB_Database($vbulletin);
            break;
        }

        
    // load MySQLi class
        
    case 'mysqli':
        {
            
    $db =& new vB_Database_MySQLi($vbulletin);
            break;
        }

        
    // load extended, non MySQL class
        
    default:
        {
            die(
    'Fatal error: Database class not found');
        }
    }

    require_once(
    './includes/functions.php');


    // make database connection
    $db->connect(
        
    $config['Database']['dbname'],
        
    $config['MasterServer']['servername'],
            
    $config['MasterServer']['port'],
        
    $config['MasterServer']['username'],
        
    $config['MasterServer']['password'],
        
    $config['MasterServer']['usepconnect'],
        
    $config['SlaveServer']['servername'],
            
    $config['SlaveServer']['username'],
        
    $config['SlaveServer']['password'],
        
    $config['SlaveServer']['usepconnect'],
        
    $config['Mysqli']['ini_file']
    );

    $vbulletin->db =& $db;

    // ---------------------------------------------------
    // End Call DB & Establish Connection
    // ---------------------------------------------------

    // ---------------------------------------------------
    // Start Require Globalized Settings
    // ---------------------------------------------------

    class vBulletinHook { function fetch_hook() { return false; } }

    define('TIMENOW'time());
    require_once(
    './includes/class_bbcode.php');
    $Data "";       // Page Output Variable


    $datastore_class = (!empty($config['Misc']['datastore'])) ? $config['Misc']['datastore'] : 'vB_Datastore';

    if (
    $datastore_class != 'vB_Datastore')
    {
        require_once(
    './includes/class_datastore.php');
    }
    $vbulletin->datastore =& new $datastore_class($vbulletin$db);
    $vbulletin->datastore->fetch($specialtemplates);

    // ---------------------------------------------------
    // End Require Globalized Settings
    // ---------------------------------------------------

        // ---------------------------------------------------
        // Start Globalized Function - LoadTemplate
        // ---------------------------------------------------

        
    function LoadTemplate($template ""){

        
    $template "vBExternal/{$template}";

            if(!
    file_exists($template)){
            
    RunError("System was unable to find the template '{$template}'");
            }

            if(!
    $Handler fopen($template,'r')){
            
    RunError("System was unable to open the template '{$template}'");
            }

        
    $template fread($Handler,filesize($template));
        
    fclose($Handler);

        return 
    $template;
        }

        
    // ---------------------------------------------------
        // End Globalized Function - LoadTemplate
        // ---------------------------------------------------

        // ---------------------------------------------------
        // Start Globalized Function - RunError
        // ---------------------------------------------------

        
    function RunError($message ""){
        echo 
    "<font size='1' face='verdana'>There was an error while processing vBExternal:
    {$message}</font>";
        exit;
        }

        
    // ---------------------------------------------------
        // End Globalized Function - RunError
        // ---------------------------------------------------

        // ---------------------------------------------------
        // Start Globalized Function - ParseTemplate
        // ---------------------------------------------------

        
    function ParseTemplate($template$parser = array(), $doGlobals 0){
        global 
    $vbulletin;

            if(
    is_array($parser)){
                foreach(
    $parser as $find => $replace){
                
    $template str_replace("{".$find."}"$replace$template);
                }
            } else if(
    $doGlobals){
            
    $RepGlobals = array(
                        
    'url' => $vbulletin->options['bburl'],
                    );

                foreach(
    $RepGlobals as $find => $replace){
                
    $template str_replace("{".$find."}"$replace$template);
                }

            }

        return 
    $template;
        }

        
    // ---------------------------------------------------
        // End Globalized Function - ParseTemplate
        // ---------------------------------------------------

        // ---------------------------------------------------
        // FUNCTION: output_NewestMembers
        // DETAIL:   Outputs newest X members in order of
            //           newest registered first. $a
        //           specifies amount to show (Default 5)
        // ---------------------------------------------------

        
    function output_NewestMembers($a 5){
        global 
    $db$Data;

        
    // Define amount to show
        
    $Amount = ($a)? intval($a) : 5;

        
    // Load Template
        
    $Template LoadTemplate("newest_members.html");

        
    // Collect Data
        
    $NewestMem $db->query("select username,posts,userid from ".TABLE_PREFIX."user order by joindate desc limit 0,$Amount");

            while(
    $Member $db->fetch_array($NewestMem)){
            
    $Data .= ParseTemplate($Template,
                                array(
                                    
    'username' => $Member['username'],
                                    
    'posts'    => vb_number_format($Member['posts']),
                                    
    'userid'   => $Member['userid'],
                                )
                );
            }

        
    doOutput();
        }

        
    // ---------------------------------------------------
        // FUNCTION: output_TopPosters
        // DETAIL:   Outputs Top X posts in order of
            //           highest post count descending. $a
        //           specifies amount to show (Default 5)
        // ---------------------------------------------------

        
    function output_TopPosters($a 5){
        global 
    $db$Data;

        
    // Define amount to show
        
    $Amount = ($a)? intval($a) : 5;

        
    // Load Template
        
    $Template LoadTemplate("newest_members.html");

        
    // Collect Data
        
    $TopPosters $db->query("select username,posts,userid from ".TABLE_PREFIX."user order by posts desc limit 0,$Amount");

            while(
    $Member $db->fetch_array($TopPosters)){
            
    $Data .= ParseTemplate($Template,
                                array(
                                    
    'username' => $Member['username'],
                                    
    'posts'    => vb_number_format($Member['posts']),
                                    
    'userid'   => $Member['userid'],
                                )
                );
            }

        
    doOutput();
        }

        
    // ---------------------------------------------------
        // FUNCTION: output_NewestThreads
        // DETAIL:   Outputs X newest threads ordered by
            //           start date descending. $a
        //           specifies amount to show (Default 5)
            //           and $f can specify certain forums
        //           to grab from (1,3,4), by default it pulls
            //           from all forums.
        // ---------------------------------------------------

        
    function output_NewestThreads($a 5,$f ""){
        global 
    $db$Data;

        
    // Define amount to show
        
    $Amount = ($a)? intval($a) : 5;

        
    // Define Forum(s) To Pull From
        
    $Forums = ($f)? $f'';
        
    $SQL    '';

            if(
    $Forums){
            
    $SQL " where forumid in({$Forums})";
            }

        
    // Load Template
        
    $Template LoadTemplate("newest_threads.html");

        
    // Collect Data
        
    $NewestThreads $db->query("select * from ".TABLE_PREFIX."thread{$SQL} order by dateline desc limit 0,$Amount");

            while(
    $Thread $db->fetch_array($NewestThreads)){
            
    $Data .= ParseTemplate($Template,
                                array(
                                    
    'threadid'     => $Thread['threadid'],
                                    
    'threadname'   => $Thread['title'],
                                    
    'postuserid'   => $Thread['postuserid'],
                                    
    'postusername' => $Thread['postusername'],
                                    
    'replies'      => vb_number_format($Thread['replycount']),
                                    
    'views'        => vb_number_format($Thread['views']),
                                    
    'lastposter'   => $Thread['lastposter'],
                                )

                );
            }

        
    doOutput();
        }

        
    // ---------------------------------------------------
        // FUNCTION: output_NewestReplies
        // DETAIL:   Outputs X newest threads ordered by
            //           last post descending. $a
        //           specifies amount to show (Default 5)
            //           and $f can specify certain forums
        //           to grab from (1,3,4), by default it pulls
            //           from all forums.
        // ---------------------------------------------------

        
    function output_NewestReplies($a 5,$f ""){
        global 
    $db$Data;

        
    // Define amount to show
        
    $Amount = ($a)? intval($a) : 5;

        
    // Define Forum(s) To Pull From
        
    $Forums = ($f)? $f'';
        
    $SQL    '';

            if(
    $Forums){
            
    $SQL " where forumid in({$Forums})";
            }

        
    // Load Template
        
    $Template LoadTemplate("newest_threads.html");

        
    // Collect Data
        
    $NewestReplies $db->query("select * from ".TABLE_PREFIX."thread{$SQL} order by lastpost desc limit 0,$Amount");

            while(
    $Thread $db->fetch_array($NewestReplies)){
            
    $Data .= ParseTemplate($Template,
                                array(
                                    
    'threadid'     => $Thread['threadid'],
                                    
    'threadname'   => $Thread['title'],
                                    
    'postuserid'   => $Thread['postuserid'],
                                    
    'postusername' => $Thread['postusername'],
                                    
    'replies'      => vb_number_format($Thread['replycount']),
                                    
    'views'        => vb_number_format($Thread['views']),
                                    
    'lastposter'   => $Thread['lastposter'],
                                )
                );
            }

        
    doOutput();
        } 

  10. #10
    sopra ho postato l'intera pagina dell'addon...qui di seguito invece trovate il "template" utilizzato per visualizzare i dati

    <fieldset>
    <legend width='50'>{threadname}</legend>
    <table cellpadding='0' cellspacing='0' border='0'>
    <tr>
    <td width='50' style='white-space:nowrap'>By:</td>
    <td width='10' style='white-space:nowrap'>{postusername}</td>
    </tr>
    </table>
    </fieldset>

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.