Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 13

Discussione: Sfondo tabella in PHP

  1. #1
    Utente di HTML.it
    Registrato dal
    Jan 2004
    Messaggi
    204

    Sfondo tabella in PHP

    Ciao a tutti
    sono nuovo di questo linguaggio...e sto cercando di modificare la grafica di un cms in php.

    Volevo aggiungere un'immagine di sfondo alla tabella che viene creata in questo punto della pagina con il seguente codice:

    // Creates a new HTML_Table object that will help us

    // to build a table holding all the products

    $table = new HTML_Table('width="100%"');


    io ho provato modificandolo così:

    $table = new HTML_Table('width="100%"' 'background="images/sfondo.jpg"');

    ma in questo modo mi esce errore e la pagina non viene visualizzata

    chiedo a voi + esperti qual'è il codice giusto per fra questo?
    Grazie ancora

  2. #2
    HTML_table è una classe.
    Bisogna vedere che argomenti si possono passare al costruttore.
    In ogni caso, anche se passasse l'argomento "background" (cosa che dubito), sarebbe separato da virgola.
    PHP LEARN - Guide, tutorial e articoli sempre aggiornati
    NUOVO: standardLib; il potente framework PHP é ora disponibile
    *******************************************
    Scarica oggi la tua copia di MtxEventManager

  3. #3
    Utente di HTML.it
    Registrato dal
    Jan 2004
    Messaggi
    204
    Grazie per l'attenzione alla mia questione
    ..ho provato a mettere la virgola

    $table = new HTML_Table('width="100%"','background="images/sfondo.jpg"');

    però ora non mi dà nessun errore..ma non viene applicato nessun sfondo

    come posso fare per risolvere questo problema?
    questo è il codice della pagina

    <?php if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );

    mm_showMyFileName(__FILE__); ?>



    <?php echo $buttons_header // The PDF, Email and Print buttons ?>

    <?php echo $browsepage_header // The heading, the category description ?>

    <?php echo $parameter_form // The Parameter search form ?>

    <?php echo $orderby_form // The sort-by, order-by form PLUS top page navigation ?>



    <?php

    $data =array(); // Holds the rows of products

    $i = 1; $row = 0; // Counters



    // Table header

    $tableheader[] = $VM_LANG->_('PHPSHOP_CART_NAME');

    $tableheader[] = $VM_LANG->_('PHPSHOP_CART_SKU');

    if( _SHOW_PRICES && $auth['show_prices'] ) {

    $tableheader[] = $VM_LANG->_('PHPSHOP_CART_PRICE');

    }

    $tableheader[] = $VM_LANG->_('PHPSHOP_PRODUCT_FORM_THUMB_IMAGE');

    $tableheader[] = $VM_LANG->_('PHPSHOP_PRODUCT_DESC_TITLE');

    if( _SHOW_PRICES && $auth['show_prices'] && USE_AS_CATALOGUE != '1' ) {

    $tableheader[] = $VM_LANG->_('PHPSHOP_CART_ACTION');

    }



    // Creates a new HTML_Table object that will help us

    // to build a table holding all the products

    $table = new HTML_Table('width="100%"','background="images/sfondo.jpg"');



    //$table->addRow( $tableheader, 'class="sectiontableheader"', 'th', true );



    foreach( $products as $product ) {



    foreach( $product as $attr => $val ) {

    // Using this we make all the variables available in the template

    // translated example: $this->set( 'product_name', $product_name );

    $this->set( $attr, $val );

    }



    // $data[$row][] = ' '.$product['product_name'].'';
    $data[$row][] = $product['product_sku'];
    //if( _SHOW_PRICES && $auth['show_prices'] ) {
    // $data[$row][] = $product['product_price'];
    //}
    $data[$row][] = '<a href="'.$product['product_flypage'].'" title="'.$product['product_name'].'">'
    . ps_product::image_tag( $product['product_thumb_image'] )
    . '</a>';
    $data[$row][] = ''.$product['product_name'].'' .'

    '
    .$product['product_s_desc'] .''; //.$product['product_details'].'';
    if( _SHOW_PRICES && $auth['show_prices'] ) {
    $data[$row][] = $product['product_price'];
    }
    if( $product['has_addtocart'] ) {
    $data[$row][] = $product['form_addtocart'];
    }
    else {
    //$data[$row][] = '<a href="'.$product['product_flypage'].'" title="'.$product['product_name'].'">'
    // . $product['product_details']
    // . '</a>';
    }
    $row++;

    }






    // Loop through each row and build the table

    foreach($data as $key => $value) {



    $table->addRow( $data[$key], 'class="sectiontableentry'.$i.'"', 'td', true );

    $i = $i == 1 ? 2 : 1;

    }

    // Display the table

    echo $table->toHtml();

    ?>

    <br class="clr" />


    <?php echo $browsepage_footer ?>

    <?php

    // Show Featured Products

    if( $this->get_cfg( 'showFeatured', 1 )) {

    /* featuredproducts(random, no_of_products,category_based) no_of_products 0 = all else numeric amount

    edit featuredproduct.tpl.php to edit layout */

    echo $ps_product->featuredProducts(true,10,true);

    } ?>

    <?php echo $recent_products ?>

  4. #4
    Ma non lo si può indovinare. Bisogna vedere la classe per capire se è possibile, e non è detto che lo sia, aggiungere un immagine di sfondo.
    PHP LEARN - Guide, tutorial e articoli sempre aggiornati
    NUOVO: standardLib; il potente framework PHP é ora disponibile
    *******************************************
    Scarica oggi la tua copia di MtxEventManager

  5. #5
    Utente di HTML.it
    Registrato dal
    Jan 2004
    Messaggi
    204
    Ho cercato nel cms
    e la classe HTML_Table viende definita in un file table.php
    di seguito la prim parte del contenuto del file table.php
    Dimmi che si può fare qualcosa
    Grazie

    <?php

    /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */



    /**

    * PEAR::HTML_Table makes the design of HTML tables easy, flexible, reusable and efficient.

    *

    * The PEAR::HTML_Table package provides methods for easy and efficient design of HTML tables.

    * - Lots of customization options.

    * - Tables can be modified at any time.

    * - The logic is the same as standard HTML editors.

    * - Handles col and rowspans.

    * - PHP code is shorter, easier to read and to maintain.

    * - Tables options can be reused.

    *

    * For auto filling of data and such then check out http://pear.php.net/package/HTML_Table_Matrix

    *

    * PHP versions 4

    *

    * LICENSE: This source file is subject to version 3.0 of the PHP license

    * that is available through the world-wide-web at the following URI:

    * http://www.php.net/license/3_0.txt. If you did not receive a copy of

    * the PHP License and are unable to obtain it through the web, please

    * send a note to license@php.net so we can mail you a copy immediately.

    *

    * @category HTML

    * @package HTML_Table

    * @author Adam Daniel <adaniel1@eesus.jnj.com>

    * @author Bertrand Mansion <bmansion@mamasam.com>

    * @copyright 2005 The PHP Group

    * @license http://www.php.net/license/3_0.txt PHP License 3.0

    * @version CVS: $Id: Table.php 1958 2009-10-08 20:09:57Z soeren_nb $

    * @link http://pear.php.net/package/HTML_Table

    */





    /**

    * Requires PEAR, HTML_Common and HTML_Table_Storage

    */

    require_once dirname(__FILE__).'/../../PEAR.php';

    require_once dirname(__FILE__).'/Common.php';

    require_once dirname(__FILE__).'/Table/Storage.php';



    /**

    * PEAR::HTML_Table makes the design of HTML tables easy, flexible, reusable and efficient.

    *

    * The PEAR::HTML_Table package provides methods for easy and efficient design of HTML tables.

    * - Lots of customization options.

    * - Tables can be modified at any time.

    * - The logic is the same as standard HTML editors.

    * - Handles col and rowspans.

    * - PHP code is shorter, easier to read and to maintain.

    * - Tables options can be reused.

    *

    * For auto filling of data and such then check out http://pear.php.net/package/HTML_Table_Matrix

    *

    * @category HTML

    * @package HTML_Table

    * @author Adam Daniel <adaniel1@eesus.jnj.com>

    * @author Bertrand Mansion <bmansion@mamasam.com>

    * @copyright 2005 The PHP Group

    * @license http://www.php.net/license/3_0.txt PHP License 3.0

    * @version Release: @package_version@

    * @link http://pear.php.net/package/HTML_Table

    */

    class HTML_Table extends HTML_Common {



    /**

    * Value to insert into empty cells

    * @var string

    * @access private

    */

    var $_autoFill = '';



    /**

    * Array containing the table caption

    * @var array

    * @access private

    */

    var $_caption = array();



    /**

    * Array containing the table column group specifications

    *

    * @var array

    * @author Laurent Laville (pear at laurent-laville dot org)

    * @access private

    */

    var $_colgroup = array();



    /**

    * HTML_Table_Storage object for the (t)head of the table

    * @var object

    * @access private

    */

    var $_thead = null;



    /**

    * HTML_Table_Storage object for the (t)foot of the table

    * @var object

    * @access private

    */

    var $_tfoot = null;



    /**

    * HTML_Table_Storage object for the (t)body of the table

    * @var object

    * @access private

    */

    var $_tbody = null;



    /**

    * Whether to use <thead>, <tfoot> and <tbody> or not

    * @var bool

    * @access private

    */

    var $_useTGroups = false;



    /**

    * Class constructor

    * @param array $attributes Associative array of table tag attributes

    * @param int $tabOffset Tab offset of the table

    * @param bool $useTGroups Whether to use <thead>, <tfoot> and

    * <tbody> or not

    * @access public

    */


    poi dopo c'è tutta la parte delle function

  6. #6
    ok, si tratta di un'estensione della classe HTML_Table di pear

    La documentazione dice che il parametro del costruttore è un array associativo

    dunque il passaggio corretto di parametri è il seguente

    $table = new HTML_Table(array('border' => '1', 'class' => 'cssclass'));

    se tu definisci la class cssclass con l'immagine di background che desideri dovrebbe funzionare

    PHP LEARN - Guide, tutorial e articoli sempre aggiornati
    NUOVO: standardLib; il potente framework PHP é ora disponibile
    *******************************************
    Scarica oggi la tua copia di MtxEventManager

  7. #7
    Utente di HTML.it
    Registrato dal
    Jan 2004
    Messaggi
    204
    Scusami ma per me è un pò complicato seguirti
    vediamo se ho capito

    nel file dove ho

    // Creates a new HTML_Table object that will help us

    // to build a table holding all the products

    $table = new HTML_Table('width="100%"');

    devo sostituirlo con

    $table = new HTML_Table(array('border' => '1', 'class' => 'cssclass'));

    però non ho capito dove e come definire la class cssclass con l'immagine di sfondo!!!


    se è una cosa complicata..lascio perdere
    scusami se ti faccio perdere tempo
    e grazie ancora

  8. #8
    Semplicemente, i parametri della tabella, sono passati con un array associativo.

    Quello che ti ho postato è solo un esempio.

    $table = new HTML_Table(array('width' => '100%', 'class' => 'quellochevuoi'));

    Così facendo aggiungi la tua classe alla tabella.

    Poi nel file di stile del template che utilizzi, crei la tua classe

    .quellochevuoi{
    background: url(nomeImmagine);
    }
    PHP LEARN - Guide, tutorial e articoli sempre aggiornati
    NUOVO: standardLib; il potente framework PHP é ora disponibile
    *******************************************
    Scarica oggi la tua copia di MtxEventManager

  9. #9
    Utente di HTML.it
    Registrato dal
    Jan 2004
    Messaggi
    204
    Ho fatto come mi hai detto
    ma non funziona!!!

    nel mio cms ci sono 2 file di stile
    1 template.css
    2 theme.css

    ho provato prima con uno..poi con l'altro

    ho provato,vedendo altre voci presenti, ad inserire gli apici prima e dopo del percorso

    .quellochevuoi{
    background: url('images/sfondo.jpg');
    }

    ho provato togliendo il punto prima

    quellochevuoi{
    background: url('images/sfondo.jpg');

    }

    ho provato inserendo # al posto del .

    #quellochevuoi{
    background: url('images/sfondo.jpg');

    }


    ho provato con l'url diverso
    .quellochevuoi{
    background: url(../images/sfondo.jpg);
    }


    NIENTE DA FARE
    Non sò più cosa fare

  10. #10
    1. controlla che il css del template sia effettivamente quello
    2. images/..... è diverso da ../images/.... sei certo di dove si trova l'immagine?

    3. Guarda il codice generato. Se nella dichiarazione della tabella c'è la classe, significa che la classe non è correttamente definita nel css o che l'immagine non è stata trovata. In caso contrario ... ci penseremo
    PHP LEARN - Guide, tutorial e articoli sempre aggiornati
    NUOVO: standardLib; il potente framework PHP é ora disponibile
    *******************************************
    Scarica oggi la tua copia di MtxEventManager

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.