Results 1 to 2 of 2
  1. #1
    Join Date
    May 2014
    Location
    UK
    Posts
    317
    Plugin Contributions
    0

    Default Really Stupid Question!!

    Following on from my post about browsing by top-level category .. we have moved on by moving all our downloads to an unlimited web host one at a time ... therefore we are opening all products to check it has moved as we go along.

    I have added a field called top-level to the Products table to store out top-level category.

    As we redisplay our updated record it makes sense to write the top-level back to this field.

    Our code is:

    PHP Code:
    <?php
    /**
     * Page Template
     *
     * Loaded automatically by index.php?main_page=product_info.<br />
     * Displays details of a typical product
     */

     //  Digi-Books Modifications - DBM#
     //
     //        21st May 2014:    DB#1 - Amend product info layout
     //        1st May 2015:    DB#2 - Add Save For Later button
     //
     //        12th December 2017:    DB#3 - ADD SERIES LINKS TO PRODUCTS *****************************************
     //        27th December 2017:    DB#4 - Check existence of series zip files on secondary server
     //
    ?>

    <div class="centerColumn" id="productGeneral">
        <!--bof Form start-->
        <?php
            
    echo zen_draw_form('cart_quantity'zen_href_link(zen_get_info_page($_GET['products_id']), zen_get_all_get_params(array('action')) . 'action=add_product'$request_type), 'post''enctype="multipart/form-data"') . "\n"
            if (
    $messageStack->size('product_info') > 0) echo $messageStack->output('product_info'); 
             if (
    $module_show_categories != 0) { require($template->get_template_dir('/tpl_modules_category_icon_display.php',DIR_WS_TEMPLATE$current_page_base,'templates'). '/tpl_modules_category_icon_display.php'); }
            if (
    PRODUCT_INFO_PREVIOUS_NEXT == or PRODUCT_INFO_PREVIOUS_NEXT == 3) { require($template->get_template_dir('/tpl_products_next_previous.php',DIR_WS_TEMPLATE$current_page_base,'templates'). '/tpl_products_next_previous.php'); } 
        
    ?>
        <br /><br /><hr>
        <?php
            
    if (zen_not_null($products_image)) { require($template->get_template_dir('/tpl_modules_main_product_image.php',DIR_WS_TEMPLATE$current_page_base,'templates'). '/tpl_modules_main_product_image.php'); }
        
    ?>
        <h1 id="productName" class="productGeneral centeredContent">
            <?php 
                
    echo $products_name;
                
    /*  HERE WE NEED TO COMVERT MODEL NUMBER TO TOP-LEVEl GENRE */
                
    if ($products_model != '') { echo '<br /><font size="2px" color="green">&nbsp;&nbsp;&nbsp;(' $products_model ')</font>'; }

                echo 
    '<br /><br /><h3 class="productGeneral centeredContent">by ' $manufacturers_name '</h3>';
                echo 
    '<br /><br /><p class="productGeneral centeredContent"><strong>(Genre: ' $chk_parent_name ')</br></strong></p>'

    /*        $the_top_level_name = $chk_parent_name;
            echo $the_top_level_name . '(' . $products_top_level . ')';


    // TRYING TO SORT TOP LEVEL

    if (!$products_top_level) {
    echo 'X';
    } else {
        echo 'OK'; }

    */

            
    ?>


        </h1>

        <?php
            
    if ($products_date_available date('Y-m-d H:i:s')) {
                if (
    $flag_show_product_info_date_available == 1) {
        
    ?>
                    <p id="productDateAvailable" class="productGeneral centeredContent"><?php echo '<br /><br /><br />' sprintf(TEXT_DATE_AVAILABLEzen_date_long($products_date_available)); ?></p>
        <?php }
            } else {
                if (
    $flag_show_product_info_date_added == 1) {
        
    ?>
                    <p id="productDateAdded" class="productGeneral centeredContent"><?php echo '<br /><br /><br />' sprintf(TEXT_DATE_ADDEDzen_date_long($products_date_added)); ?></p>
        <?php 
            }
        
            if (
    $products_description != '') { 
        
    ?>
                <div id="productDescription" class="productGeneral biggerText">
                    <br /><hr><br />
                    <?php 
                        
    echo stripslashes($products_description); 
                    
    ?>
                    <hr>
                </div>
        <?php 
            

        
    ?>

        <br class="clearBoth" />

        <div class="content" align="center">

        <!-- Now test for series file links -->
        <?php
            
    if ($product_series_link != '') {
                
    $download_site "http://digi-books.org/series/";
                
    $epub_link $download_site $product_series_link '_EPUB.zip';
                
    $epub_download "http://digi-books.org/download.php?f=/series/" $product_series_link '_EPUB.zip';
                
    $mobi_link $download_site $product_series_link '_MOBI.zip';
                
    $mobi_download "http://digi-books.org/download.php?f=/series/" $product_series_link '_MOBI.zip';

                
    $first_spacer '&nbsp;&nbsp;&nbsp;&nbsp;';
                
    $output_series_links ='';

        
                if (
    fopen($epub_link"r")) {
                    
    $output_series_links .= '<a href="' $epub_download '"><img src="includes/templates/fresh/images/series_epub.gif"></a>' ;
                } else {
                    
    $output_series_links .= '<img src="includes/templates/fresh/images/no_series_epub.gif">';
                }
                
                if (
    fopen($mobi_link"r")) {
                    
    $output_series_links .= $first_spacer '<a href="' $mobi_download '"><img src="includes/templates/fresh/images/series_mobi.gif"></a>' ;
                } else {
                    
    $output_series_links .= $first_spacer '<img src="includes/templates/fresh/images/no_series_mobi.gif">';
                }
            
            }

            
    $this_book_number =(int)$_GET['products_id'];

            
    // Use the book number to obtain the zip download reference in the attributes table -->
            
    $pull_zip_id $db->Execute("select products_attributes_id, products_id from " TABLE_PRODUCTS_ATTRIBUTES " where products_id='" . (int)$_GET['products_id'] . "'");
            
    $zip_file_id $pull_zip_id->fields['products_attributes_id'];
        
            
    // Extract the zip filename from the attributes download table
            
    $zipfile_name $db->Execute("select products_attributes_id, products_attributes_filename from " TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD " where products_attributes_id='" . (int)$zip_file_id "'");

            
    $the_zip_file $zipfile_name->fields['products_attributes_filename'];
            
    $the_book_file $the_zip_file;
            
    // Check the primary server now for the zip file
            
    $primary_site "http://digi-books.org.uk/bookshelf/download/";
            
    $zip_file_link $primary_site $the_zip_file;

            
    $filename '../bookshelf/download/' $the_zip_file;
    // ***** THIS HAS TO BE TWO BACKWARD DIRECTORIES FOR THE ADMIN TEAM LIBRARY *****

            
    $zip_file_download "http://digi-books.org.uk/download.php?f=/bookshelf/download/" $the_zip_file;

            if (
    file_exists($filename)) {
                
    // display a direct download link to the book zip file
                
    $output_series_links .= $first_spacer '<a href="' $zip_file_download '"><img src="includes/templates/fresh/images/download_book.jpg"></a>';
            } else {


                
    //***  Now check for the existence of books on the Secondary Server

                
    $book_site "http://digi-books.org/ebooks/";
                
    $book_epub $book_site $the_book_file '.epub';
                
    $book_mobi $book_site $the_book_file '.mobi';


                
    $check_epub $book_epub;
                
    $check_mobi $book_mobi;


                
    $is_on_server2=0;

                if (
    fopen($book_epub"r")) {
                    
    $output_series_links .= $first_spacer '<a href="' $book_epub '"><img src="includes/templates/fresh/images/download_epub.jpg"></a>';
                    
    $is_on_server2=1;
                }

                if (
    fopen($book_mobi"r")) {
                    
    $output_series_links .= $first_spacer '<a href="' $book_mobi '"><img src="includes/templates/fresh/images/download_mobi.jpg"></a>';
                    
    $is_on_server2=1;
                }

                if (!
    $is_on_server2){
                    
    $output_series_links .= $first_spacer '<img src="includes/templates/fresh/images/download_unavailable.jpg">';
                }
            }

            echo 
    $output_series_links '<hr>';
        
    ?>
        </div>
        

        <?php 
            
    if (PRODUCT_INFO_PREVIOUS_NEXT == or PRODUCT_INFO_PREVIOUS_NEXT == 3) {
                require(
    $template->get_template_dir('/tpl_products_next_previous.php',DIR_WS_TEMPLATE$current_page_base,'templates'). '/tpl_products_next_previous.php');
            }
        
    ?>
        <!--eof Prev/Next bottom position -->



    <!-- ************** FURTHER TIDYING TO DO FROM HERE -->
    <!-- ****** AS FAR AS I CAN SEE NONE OF THE FOLLOWING IS NEEDED ***** -->

        <!--bof Attributes Module -->
        <!-- display the product attributes -->

        <?php
            
    if ($pr_attr->fields['total'] > 0) {
                require(
    $template->get_template_dir('/tpl_modules_attributes.php',DIR_WS_TEMPLATE$current_page_base,'templates'). '/tpl_modules_attributes.php'); 
            }
        
    ?>
        <!--eof Attributes Module -->




        <!--bof also purchased products module-->
    <!-- <?php require($template->get_template_dir('tpl_modules_also_purchased_products.php'DIR_WS_TEMPLATE$current_page_base,'templates'). '/' 'tpl_modules_also_purchased_products.php');?> -->
        <!--eof also purchased products module-->

    <!--bof Form close-->
    </form>
    <!--bof Form close-->
    </div>
    I would be grateful if someone could explain how we can write the top-level back from here please

    Thank you

  2. #2
    Join Date
    Jul 2012
    Posts
    13,534
    Plugin Contributions
    16

    Default Re: Really Stupid Question!!

    If understand correctly, when at this code point:
    Code:
    /*################$the_top_level_name##=##$chk_parent_name;
    ################echo##$the_top_level_name##.##'('##.##$products_top_level##.##')';
    
    
    //##TRYING##TO##SORT##TOP##LEVEL
    
    if##(!$products_top_level)##{
    echo##'X';
    }##else##{
    ########echo##'OK';##}
    
    */
    Want that logic to update information in the database.

    So on whichever side of the if statement is to do the update:
    Code:
    $sql = "UPDATE " . TABLE_PRODUCTS . " SET products_model = :new_model: WHERE products_id = :products_id:";
    $sql = $db->bindVars($sql, ':new_model:', $products_top_level, 'string');
    $sql = $db->bindVars($sql, ':products_id:', $_GET['products_id'], 'integer');
    
    $db->Execute($sql);
    Now, depending on to which version of ZC this is applied the existence of the word null in $products_top_level or whatever variable ends up being used for the new model may have an undesirable effect. I've lost track of whether it is an issue for all caps or lower case only, but if you expect null to be in the text and you want to all the word null to be present and again depending on the version, may want to replace string with stringIgnoreNull. But, if that filter option is not available in your version, then just use string until the next upgrade.

    Will say that regarding the code above that all of the hard coding of paths, servers, etc will cause a lot of heartache later if/when those paths have to be changed. For some of the code (images for example) there are built in ZC functions that can generate those paths for you from the existing information about the site. But that's a different issue than what has been discussed.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...
    Upgraded to Zen Cart V1.5.3 from V1.5.1 from V1.5.0 from V1.3.9h

 

 

Similar Threads

  1. a really stupid question about cloning order total modules
    By delia in forum Contribution-Writing Guidelines
    Replies: 0
    Last Post: 11 Aug 2011, 02:04 PM
  2. Are people really this stupid ????
    By PatF in forum General Questions
    Replies: 9
    Last Post: 18 Dec 2008, 04:59 PM
  3. really stupid question!!!
    By jleenyc in forum General Questions
    Replies: 6
    Last Post: 26 Mar 2008, 12:51 AM
  4. I feel really stupid here, customer phone number question
    By Ripper in forum General Questions
    Replies: 6
    Last Post: 21 Mar 2007, 07:37 AM

Bookmarks

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
Zen-Cart, Internet Selling Services, Klamath Falls, OR