Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 2009
    Posts
    155
    Plugin Contributions
    1

    Default Query to Alternate Row Colors in Download Table

    I'd like to change my downloads table in 1.3.8a to display alternating row colors. I've been working with tpl_modules_downloads to try and accomplish that, but I'm stuck at the proper query for <tr class>. I found some threads asking the same thing about the ProductListing table, but I couldn't seem to successfully adapt the code to the downloads table.

    Thanks a bunch for your help! :)

  2. #2
    Join Date
    Apr 2009
    Posts
    2,134
    Plugin Contributions
    3

    Default Re: Query to Alternate Row Colors in Download Table

    Quote Originally Posted by ToniScraparoni View Post
    I'd like to change my downloads table in 1.3.8a to display alternating row colors. I've been working with tpl_modules_downloads to try and accomplish that, but I'm stuck at the proper query for <tr class>. I found some threads asking the same thing about the ProductListing table, but I couldn't seem to successfully adapt the code to the downloads table.

    Thanks a bunch for your help! :)
    As far as the product listing table goes the effect is created by css. The classes for alternate rows are included in the code so it is just a matter of writing two css rules.

    The classes are :

    Code:
    .productListing-odd
    .productListing-even
    Unfortunately, as far as tpl_modules_downloads goes there are not corresponding classes built into the existing code. With a bit of PHP you could easily add an incremented variable to the 'while' and use that to add a class to the <tr> based on whether the incremented variable was odd or even. Then stlye those new classes in the css.

    If that seems a bit confusing email me (click on my name to the left) and I'll get into it with you.

    Nik

  3. #3
    Join Date
    Apr 2009
    Posts
    2,134
    Plugin Contributions
    3

    Default Re: Query to Alternate Row Colors in Download Table

    I can't test this at the moment but what I am talking about is something like the edits is the following code:

    Code:
    <!-- list of products -->
    
    <?php
    
        $AAA=0//NICCOL
        while (!$downloads->EOF) {
        $AAA++;//NICCOL
        $AAF= floor($AAA/2);//NICCOL
        if ($AAF=($AAA/2){$row_class="download-even";}//NICCOL
        else{$row_class="download-odd";}//NICCOL
    
    // MySQL 3.22 does not have INTERVAL
          list($dt_year, $dt_month, $dt_day) = explode('-', $downloads->fields['date_purchased_day']);
          $download_timestamp = mktime(23, 59, 59, $dt_month, $dt_day + $downloads->fields['download_maxdays'], $dt_year);
          $download_expiry = date('Y-m-d H:i:s', $download_timestamp);
    
          $is_downloadable = ( (file_exists(DIR_FS_DOWNLOAD . $downloads->fields['orders_products_filename']) && (($downloads->fields['download_count'] > 0 && $download_timestamp > time()) || $downloads->fields['download_maxdays'] == 0)) ) ? true : false;
          $zv_filesize = filesize (DIR_FS_DOWNLOAD . $downloads->fields['orders_products_filename']);
          if ($zv_filesize >= 1024) {
            $zv_filesize = number_format($zv_filesize/1024/1024,2);
            $zv_filesize_units = TEXT_FILESIZE_MEGS;
          } else {
            $zv_filesize = number_format($zv_filesize);
            $zv_filesize_units = TEXT_FILESIZE_BYTES;
          }
    ?>
              <tr class="tableRow<?php echo ' '.$row_class; ?>">
    <!-- left box -->
    If you compare it to your existing file you should see which bits to add. That should create two new classes in the code. The classes will be:

    .download-even
    .download-odd

    But as I say I am not in a position to test this so it may have lots of typos in it. But the theory should work. Got to sleep now :-)

    Nik

  4. #4
    Join Date
    Apr 2009
    Posts
    155
    Plugin Contributions
    1

    Default Re: Query to Alternate Row Colors in Download Table

    Hi, Nik!

    Thanks for trying to help me. It doesn't work. LOL! I think there might be a parentheses missing, but it doesn't matter where I insert it ... adding this code widens the table so it covers the entire right column, with no changes to row background color. I had been trying to tie in with the classes rowOdd and rowEven, already in the stylesheet.

    Thanks a bunch! Hope you're having sweet Zen dreams and the fix will come to you by [your] morning. ;)

  5. #5
    Join Date
    Apr 2009
    Posts
    2,134
    Plugin Contributions
    3

    Default Re: Query to Alternate Row Colors in Download Table

    Sorry about that. I guess that is what comes of writing code late at night and not being ale to test it :-) I'll look at it later today when I will be able to test it. A URL would help.

  6. #6
    Join Date
    Apr 2009
    Posts
    155
    Plugin Contributions
    1

    Default Re: Query to Alternate Row Colors in Download Table

    Hi, Nik!

    Got your email, will reply. TY! :)

  7. #7
    Join Date
    Apr 2009
    Posts
    155
    Plugin Contributions
    1

    Default Re: Query to Alternate Row Colors in Download Table

    Posting back to say a VERY big thank-you to Nick, who so generously gave of his time to help me figure this out. We have a download table with alternating row colors, their classes tying back to the already built-in rowOdd and rowEven.

    Except for one I couldn't figure out what it tied to, (maybe from the Order History table?) I went ahead and assigned classes to the rest of the table and changed the header classes to correspond, making it much easier for additional styling. Yippee!!

    For anyone else who would like the code, here's a new copy of tpl_modules_downloads.php:

    PHP Code:
    <?php
    /**
     * Module Template
     *
     * @package templateSystem
     * @copyright Copyright 2003-2006 Zen Cart Development Team
     * @copyright Portions Copyright 2003 osCommerce
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     * @version $Id: tpl_modules_downloads.php 6374 2007-05-25 20:24:42Z drbyte $
     */
    /**
     * require the downloads module
     */
      
    require(DIR_WS_MODULES zen_get_module_directory('downloads.php'));
    ?>

    <?php
    // download is available
      
    if ($downloads->RecordCount() > 0) {
    ?>

    <table border="0" width="100%" cellspacing="0" cellpadding="0" id="downloads">
    <caption><h4><?php echo HEADING_DOWNLOAD?></h4></caption>
      <tr class="tableHeading">
          <th scope="col" id="dlItemNameHeading"><?php echo TABLE_HEADING_PRODUCT_NAME?></th>
          <th scope="col" id="dlFileSizeHeading"><?php echo TABLE_HEADING_BYTE_SIZE?></th>
          <th scope="col" id="dlFileNameHeading"><?php echo TABLE_HEADING_DOWNLOAD_FILENAME?></th>
          <th scope="col" id="dlDateHeading"><?php echo TABLE_HEADING_DOWNLOAD_DATE?></th>
          <th scope="col" id="dlCountHeading"><?php echo TABLE_HEADING_DOWNLOAD_COUNT?></th>
          <th scope="col" id="dlButtonHeading">&nbsp;</th>
              </tr>
    <!-- list of products -->

    <?php

        $AAA
    =0;//NICCOL
        
    while (!$downloads->EOF) {
        
    $AAA++;
        if (
    $AAA 2){$row_class="rowEven";}
        else{
    $row_class="rowOdd";}//NICCOL

    // MySQL 3.22 does not have INTERVAL
          
    list($dt_year$dt_month$dt_day) = explode('-'$downloads->fields['date_purchased_day']);
          
    $download_timestamp mktime(235959$dt_month$dt_day $downloads->fields['download_maxdays'], $dt_year);
          
    $download_expiry date('Y-m-d H:i:s'$download_timestamp);

          
    $is_downloadable = ( (file_exists(DIR_FS_DOWNLOAD $downloads->fields['orders_products_filename']) && (($downloads->fields['download_count'] > && $download_timestamp time()) || $downloads->fields['download_maxdays'] == 0)) ) ? true false;
          
    $zv_filesize filesize (DIR_FS_DOWNLOAD $downloads->fields['orders_products_filename']);
          if (
    $zv_filesize >= 1024) {
            
    $zv_filesize number_format($zv_filesize/1024/1024,2);
            
    $zv_filesize_units TEXT_FILESIZE_MEGS;
          } else {
            
    $zv_filesize number_format($zv_filesize);
            
    $zv_filesize_units TEXT_FILESIZE_BYTES;
          }
    ?>
              <tr class="tableRow<?php echo ' '.$row_class?>">
    <!-- left box -->
    <?php
    // The link will appear only if:
    // - Download remaining count is > 0, AND
    // - The file is present in the DOWNLOAD directory, AND EITHER
    // - No expiry date is enforced (maxdays == 0), OR
    // - The expiry date is not reached

    //      if ( ($downloads->fields['download_count'] > 0) && (file_exists(DIR_FS_DOWNLOAD . $downloads->fields['orders_products_filename'])) && ( ($downloads->fields['download_maxdays'] == 0) || ($download_timestamp > time())) ) {
          
    if  ($is_downloadable) {
    ?>
          <td class="dlItemName"><?php echo '<a href="' zen_href_link(FILENAME_DOWNLOAD'order=' $last_order '&id=' $downloads->fields['orders_products_download_id']) . '">' $downloads->fields['products_name'] . '</a>'?></td>
    <?php } else { ?>
          <td class=""><?php echo $downloads->fields['products_name']; ?></td>
    <?php
          
    }
    ?>
          <td class="dlFileSize"><?php echo $zv_filesize $zv_filesize_units?></td>
          <td class="dlFileName"><?php echo $downloads->fields['orders_products_filename']; ?></td>
          <td class="dlDate"><?php echo ($downloads->fields['download_maxdays'] == TEXT_DOWNLOADS_UNLIMITED zen_date_short($download_expiry)); ?></td>
          <td class="dlCount"><?php echo ($downloads->fields['download_maxdays'] == TEXT_DOWNLOADS_UNLIMITED_COUNT $downloads->fields['download_count']); ?></td>
          <td class="centeredContent"><?php echo ($is_downloadable) ? '<a href="' zen_href_link(FILENAME_DOWNLOAD'order=' $last_order '&id=' $downloads->fields['orders_products_download_id']) . '">' zen_image_button(BUTTON_IMAGE_DOWNLOADBUTTON_DOWNLOAD_ALT) . '</a>' '&nbsp;'?></td>
        </tr>
    <?php
        $downloads
    ->MoveNext();
        }
    ?>
      </table>

    <?php
    // old way
    //    if (!strstr($PHP_SELF, FILENAME_ACCOUNT_HISTORY_INFO)) {
    // new way
          
    if (!($_GET['main_page']==FILENAME_ACCOUNT_HISTORY_INFO)) {
    ?>
    <p><?php printf(FOOTER_DOWNLOAD'<a href="' zen_href_link(FILENAME_ACCOUNT'''SSL') . '">' HEADER_TITLE_MY_ACCOUNT '</a>'); ?></p>
    <?php } else { ?>
    <?php
    // other pages if needed
          
    }
    ?>

    <?php
    // $downloads->RecordCount() > 0
    ?>

    <?php
    // download is not available yet
    if ($downloads_check_query->RecordCount() > and $downloads->RecordCount() < 1) {
    ?>
     <fieldset><?php echo DOWNLOADS_CONTROLLER_ON_HOLD_MSG ?></fieldset>
    <?php
    }
    ?>
    Thank you again, Nick! It was a pleasure "working" with you!

 

 

Similar Threads

  1. v153 Digital download product: shipping added on alternate attribute option
    By RixStix in forum Built-in Shipping and Payment Modules
    Replies: 8
    Last Post: 15 Feb 2015, 01:07 AM
  2. Download Folder on alternate server?
    By bowserhound in forum General Questions
    Replies: 2
    Last Post: 7 Jun 2010, 03:24 AM
  3. Product Grid Layout - Alternating row colors
    By samkarpluk in forum Setting Up Categories, Products, Attributes
    Replies: 1
    Last Post: 29 Sep 2007, 09:05 PM
  4. Odd & Even Row Colors, Duplicating a Category
    By splinter79 in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 20 Oct 2006, 03:23 AM
  5. a couple ? background, extra white space, row colors
    By bwhitmire in forum Templates, Stylesheets, Page Layout
    Replies: 7
    Last Post: 13 Jul 2006, 03:04 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg