Zen Cart Logo
Forums / General Questions / Display product info in the left sidebar

Display product info in the left sidebar

Locked

Views: 1,323

Results 1 to 4 of 4
This thread is locked. New replies are disabled.
25 Oct 2009, 10:12 PM
#1
jwburnside avatar

jwburnside

New Zenner

Join Date:
Jun 2009
Posts:
35
Plugin Contributions:
0

Display product info in the left sidebar

Hey everyone, I am trying to display some of the product information in the sidebars. I just copied over a few pieces of code from tpl_product_info_display into tpl_box_default_left and right, and it seems to work well in the right sidebar, but not in the left. For example, I can get the product price to show up, but not the product image or the attributes.
I'm pretty sure it has to do with the order that the page elements are generated, but I can't figure out where the variables for product image and attributes are defined. Can anyone shed some light on this? Thanks,

JW

25 Oct 2009, 11:32 PM
#2
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: Display product info in the left sidebar

They're defined in includes/modules/pages/product_info/main_template_vars.php. But the variables processed there will only be available on the product_info page.

25 Oct 2009, 11:34 PM
#3
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: Display product info in the left sidebar

They're defined for the tpl_product_info_display template in includes/modules/pages/product_info/main_template_vars.php. But the variables processed there will only be available on the product_info page.

Depending upon when you want to display them, you may have to extract them from the database and prepare them yourself. The product sideboxes show how.

26 Oct 2009, 12:50 AM
#4
jwburnside avatar

jwburnside

New Zenner

Join Date:
Jun 2009
Posts:
35
Plugin Contributions:
0

Re: Display product info in the left sidebar

Thanks. That seems to work fine, except now I am getting more than one of each of these things in the sidebar. The order is going like this:

Image
Attributes
Image
Attributes
Attributes

But I only have them displayed in the code one time. Any idea why multiple instances are being output?

Here is the code in case it will clear things up:

<!--JW - modified sidebar to display product information-->
<?php 
if ($_GET['main_page'] == 'product_info') 
{ ?>

<?php

 $sql = "select p.products_id, pd.products_name, pd.products_description, pd.products_description2, pd.products_description3, p.products_model, p.products_quantity, p.products_image,
                  pd.products_url, p.products_price,
                  p.products_tax_class_id, p.products_date_added,
                  p.products_date_available, p.manufacturers_id, p.products_quantity,
                  p.products_weight, p.products_priced_by_attribute, p.product_is_free,
                  p.products_qty_box_status,
                  p.products_quantity_order_max,
                  p.products_discount_type, p.products_discount_type_from, p.products_sort_order, p.products_price_sorter
           from   " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
           where  p.products_status = '1'
           and    p.products_id = '" . (int)$_GET['products_id'] . "'
           and    pd.products_id = p.products_id
           and    pd.language_id = '" . (int)$_SESSION['languages_id'] . "'";

    $product_info = $db->Execute($sql);

if ($product_info->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == '1') {
    $products_image = PRODUCTS_IMAGE_NO_IMAGE;
  } else {
    $products_image = $product_info->fields['products_image'];
  }

// set flag for attributes module usage:
    $flag_show_weight_attrib_for_this_prod_type = SHOW_PRODUCT_INFO_WEIGHT_ATTRIBUTES;
// get attributes
    require(DIR_WS_MODULES . zen_get_module_directory(FILENAME_ATTRIBUTES));

?>

<div id="sidebar_mod">

<!--bof Main Product Image -->
<?php
  if (zen_not_null($products_image)) {
  ?>
<?php
/**
 * display the main product 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'); ?>
<?php
  }
?>
<!--eof Main Product Image-->

<br class="clearBoth" />

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

</div><!--end sidebar mod-->

<?php } else { ?>

<!--End modified sidebar-->

...then the original sidebar code