Forums / Templates, Stylesheets, Page Layout / Adjust Featured Sidebox Layout to Match Bestsellers Sidebox Layout

Adjust Featured Sidebox Layout to Match Bestsellers Sidebox Layout

Views: 959

Results 1 to 8 of 8
10 Apr 2013, 9:03 PM
#1
gaffettape avatar

gaffettape

Zen Follower

Join Date:
May 2009
Posts:
433
Plugin Contributions:
0

Adjust Featured Sidebox Layout to Match Bestsellers Sidebox Layout

Hi,

Would it be possible to adjust the layout of the featured sidebox to match the layout of the bestsellers sidebox?

I'd like my featured sidebox to display a simple list of links to featured products, with no images or prices - just like the contents of the bestsellers sidebox, if possible.

Any help is much appreciated.

Thanks :smile:

10 Apr 2013, 9:40 PM
#2
stevesh avatar

stevesh

Black Belt

Join Date:
Feb 2005
Location:
Lansing, Michigan USA
Posts:
19,793
Plugin Contributions:
2

Re: Adjust Featured Sidebox Layout to Match Bestsellers Sidebox Layout

You could edit includes/templates/template_default/sideboxes/tpl_featured.php to remove the image and price and save the edited file to your custom template folder. Can't help with adding the numeration (1. 2. etc.)

11 Apr 2013, 2:28 AM
#3
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Adjust Featured Sidebox Layout to Match Bestsellers Sidebox Layout

For the numeration, you would need to change the series of divs output to an ordered list.

 * @version $Id: tpl_featured.php 18698 2011-05-04 14:50:06Z wilt $
 */
  $content = "";
  $content .= '<div class="sideBoxContent centeredContent">';
  $featured_box_counter = 0;
  while (!$random_featured_product->EOF) {
    $featured_box_counter++;
    $featured_box_price = zen_get_products_display_price($random_featured_product->fields['products_id']);
    $content .= "\n" . '  <div class="sideBoxContentItem">';
    $content .=  '<a href="' . zen_href_link(zen_get_info_page($random_featured_product->fields["products_id"]), 'cPath=' . zen_get_generated_category_path_rev($random_featured_product->fields["master_categories_id"]) . '&products_id=' . $random_featured_product->fields["products_id"]) . '">' . zen_image(DIR_WS_IMAGES . $random_featured_product->fields['products_image'], $random_featured_product->fields['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT);
    $content .= '<br />' . $random_featured_product->fields['products_name'] . '</a>';
    $content .= '<div>' . $featured_box_price . '</div>';
    $content .= '</div>';
    $random_featured_product->MoveNextRandom();
  }
  $content .= '</div>' . "\n";
 * @version $Id: tpl_featured.php 18698 2011-05-04 14:50:06Z wilt $   change to ordered list - gjh42  2013-04-13
 */
  $content = "";
  $content .= '<div class="sideBoxContent centeredContent">';
  $content .= '<ol>';
  $featured_box_counter = 0;
  while (!$random_featured_product->EOF) {
    $featured_box_counter++;
    $featured_box_price = zen_get_products_display_price($random_featured_product->fields['products_id']);
    $content .= "\n" . '  <li class="sideBoxContentItem">';
    $content .=  '<a href="' . zen_href_link(zen_get_info_page($random_featured_product->fields["products_id"]), 'cPath=' . zen_get_generated_category_path_rev($random_featured_product->fields["master_categories_id"]) . '&products_id=' . $random_featured_product->fields["products_id"]) . '">' . zen_image(DIR_WS_IMAGES . $random_featured_product->fields['products_image'], $random_featured_product->fields['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT);
    $content .= '<br />' . $random_featured_product->fields['products_name'] . '</a>';
    $content .= '<div>' . $featured_box_price . '</div>';
    $content .= '</li>';
    $random_featured_product->MoveNextRandom();
  }
  $content .= '</ol></div>' . "\n";

You can make the items have numbers simply by adding a rule .sideBoxContentItem {display: list-item; list-style-type: decimal;}, but the numbers will all be 0. without the actual <ol> structure.

11 Apr 2013, 7:50 PM
#4
gaffettape avatar

gaffettape

Zen Follower

Join Date:
May 2009
Posts:
433
Plugin Contributions:
0

Re: Adjust Featured Sidebox Layout to Match Bestsellers Sidebox Layout

Thanks for the suggestions so far guys.

stevesh:

You could edit includes/templates/template_default/sideboxes/tpl_featured.php to remove the image and price and save the edited file to your custom template folder. Can't help with adding the numeration (1. 2. etc.)

...I'm not able to remove the image and price myself, I don't know my way around PHP enough :blush:

I'm using the default includes/templates/template_default/sideboxes/tpl_featured.php file:

<?php
/**
 * Side Box Template
 *
 * @package templateSystem
 * @copyright Copyright 2003-2011 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_featured.php 18698 2011-05-04 14:50:06Z wilt $
 */
  $content = "";
  $content .= '<div class="sideBoxContent centeredContent">';
  $featured_box_counter = 0;
  while (!$random_featured_product->EOF) {
    $featured_box_counter++;
    $featured_box_price = zen_get_products_display_price($random_featured_product->fields['products_id']);
    $content .= "\n" . '  <div class="sideBoxContentItem">';
    $content .=  '<a href="' . zen_href_link(zen_get_info_page($random_featured_product->fields["products_id"]), 'cPath=' . zen_get_generated_category_path_rev($random_featured_product->fields["master_categories_id"]) . '&products_id=' . $random_featured_product->fields["products_id"]) . '">' . zen_image(DIR_WS_IMAGES . $random_featured_product->fields['products_image'], $random_featured_product->fields['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT);
    $content .= '<br />' . $random_featured_product->fields['products_name'] . '</a>';
    $content .= '<div>' . $featured_box_price . '</div>';
    $content .= '</div>';
    $random_featured_product->MoveNextRandom();
  }
  $content .= '</div>' . "\n";

Would it be easier copy the contents of the includes/templates/template_default/sideboxes/tpl_best_sellers.php file (below), and edit it to show featured products instead? Then take that edited code and place it in the tpl_featured.php file (I have no idea how easy or hard this would be - apologies if it's a ridiculous idea!)

<?php
/**
 * Side Box Template
 *
 * @package templateSystem
 * @copyright Copyright 2003-2005 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_best_sellers.php 2982 2006-02-07 07:56:41Z birdbrain $
 */
  $content = '';
  $content .= '<div id="' . str_replace('_', '-', $box_id . 'Content') . '" class="sideBoxContent">' . "\n";
  $content .= '<div class="wrapper">' . "\n" . '<ol>' . "\n";
  for ($i=1; $i<=sizeof($bestsellers_list); $i++) {
    $content .= '<li><a href="' . zen_href_link(zen_get_info_page($bestsellers_list[$i]['id']), 'products_id=' . $bestsellers_list[$i]['id']) . '">' . zen_trunc_string($bestsellers_list[$i]['name'], BEST_SELLERS_TRUNCATE, BEST_SELLERS_TRUNCATE_MORE) . '</a></li>' . "\n";
  }
  $content .= '</ol>' . "\n";
  $content .= '</div>' . "\n";
  $content .= '</div>';
?>

Thanks :smile:

11 Apr 2013, 8:04 PM
#5
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Adjust Featured Sidebox Layout to Match Bestsellers Sidebox Layout

Removing the price and image is just a matter of commenting out a few lines: ```php
/*
...

  • @version $Id: tpl_featured.php 18698 2011-05-04 14:50:06Z wilt $ change to ordered list, remove price, image - gjh42 2013-04-11
    /
    $content = "";
    $content .= '<div class="sideBoxContent centeredContent">';
    $content .= '<ol>';
    $featured_box_counter = 0;
    while (!$random_featured_product->EOF) {
    $featured_box_counter++;
    //$featured_box_price = zen_get_products_display_price($random_featured_product->fields['products_id']);
    $content .= "\n" . ' <li class="sideBoxContentItem">';
    $content .= '<a href="' . zen_href_link(zen_get_info_page($random_featured_product->fields["products_id"]), 'cPath=' . zen_get_generated_category_path_rev($random_featured_product->fields["master_categories_id"]) . '&products_id=' . $random_featured_product->fields["products_id"]) . '">' /
    . zen_image(DIR_WS_IMAGES . $random_featured_product->fields['products_image'], $random_featured_product->fields['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT)*/;
    $content .= '<br />' . $random_featured_product->fields['products_name'] . '</a>';
    //$content .= '<div>' . $featured_box_price . '</div>';
    $content .= '</li>';
    $random_featured_product->MoveNextRandom();
    }
    $content .= '</ol></div>' . "\n";
11 Apr 2013, 8:17 PM
#6
gaffettape avatar

gaffettape

Zen Follower

Join Date:
May 2009
Posts:
433
Plugin Contributions:
0

Re: Adjust Featured Sidebox Layout to Match Bestsellers Sidebox Layout

Hi Glenn,

Thanks for the response.

I'm getting "PHP Parse error: syntax error, unexpected ';' \includes\templates\my_template\sideboxes\tpl_featured.php on line 19"

12 Apr 2013, 12:17 AM
#7
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Adjust Featured Sidebox Layout to Match Bestsellers Sidebox Layout

That's odd... Line 19 in the edited file should be the long line with the <a href... and I can't find any syntax error in the way I commented out the image code there. Is that line 19 for you? Post what you have so I can compare. Did you copy/paste the code from my post?

The two $featured_box_counter lines can be deleted, as they are not used for anything here or elsewhere in stock v1.5.1. You can also delete the price div line, and the whole /. zen_image(... _HEIGHT)/ commented section, to clean up the working copy of the file.
Do you still get the error after this?

12 Apr 2013, 2:36 AM
#8
gaffettape avatar

gaffettape

Zen Follower

Join Date:
May 2009
Posts:
433
Plugin Contributions:
0

Re: Adjust Featured Sidebox Layout to Match Bestsellers Sidebox Layout

gjh42:

That's odd... Line 19 in the edited file should be the long line with the <a href... and I can't find any syntax error in the way I commented out the image code there. Is that line 19 for you? Post what you have so I can compare. Did you copy/paste the code from my post?

The two $featured_box_counter lines can be deleted, as they are not used for anything here or elsewhere in stock v1.5.1. You can also delete the price div line, and the whole /. zen_image(... _HEIGHT)/ commented section, to clean up the working copy of the file.
Do you still get the error after this?

Hi Glenn,

Deleting the lines as you suggested, rather than commenting out, seems to of worked. I must of made a mistake when editing the file initially. Everything looks good my end now.

Thanks for your help :smile: