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 == 1 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"> (' . $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_AVAILABLE, zen_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_ADDED, zen_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 = ' ';
$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 == 1 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
Bookmarks