Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2016
    Location
    Norcatur, Kansas, USA
    Posts
    80
    Plugin Contributions
    3

    Idea or Suggestion How to change product attribute image swatches to display side-by-side

    Okay, I have my website up for selling sheds on, and I have an option for shingle color. Each of the option values has an image for the color of each shingle type.

    Zencart was showing these image swatches in a vertical line, and I was really unhappy with it, and started researching how to change this. I found this thread here but it didn't seem to help. So, being a hobbyist programmer, I started searching and experimenting with the PHP files and finally found where I could change a line to remove "<br class="clearBoth>" from between the image swatches to display them side-by-side:

    Name:  demoswatch.jpg
Views: 414
Size:  79.2 KB

    Where I finally found this change to make was in the "/includes/modules/attributes.php" file. Line 478 has the text:

    $tmp_attributes_image .= '<br class="clearBoth">' . "\n";

    Here is the section of code starting about line 470:

    Code:
    // collect attribute image if it exists and to be drawn in table below
                      if ($products_options_names->fields['products_options_images_style'] == '0' or ($products_options_names->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_FILE or $products_options_names->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_TEXT or $products_options_names->fields['products_options_type'] == '0') ) {
                        if ($products_options->fields['attributes_image'] != '') {
                          $tmp_attributes_image_row++;
    
                          //              if ($tmp_attributes_image_row > PRODUCTS_IMAGES_ATTRIBUTES_PER_ROW) {
                          if ($tmp_attributes_image_row > $products_options_names->fields['products_options_images_per_row']) {
                            $tmp_attributes_image .= '<br class="clearBoth">' . "\n";
                            $tmp_attributes_image_row = 1;
                          }
    
                          $tmp_attributes_image .= '<div class="attribImg">' . zen_image(DIR_WS_IMAGES . $products_options->fields['attributes_image']) . (PRODUCT_IMAGES_ATTRIBUTES_NAMES == '1' ? '<br />' . $products_options->fields['products_options_values_name'] : '') . '</div>' . "\n";
                        }
                      }
    Change it like this:

    Code:
    // collect attribute image if it exists and to be drawn in table below
                      if ($products_options_names->fields['products_options_images_style'] == '0' or ($products_options_names->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_FILE or $products_options_names->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_TEXT or $products_options_names->fields['products_options_type'] == '0') ) {
                        if ($products_options->fields['attributes_image'] != '') {
                          $tmp_attributes_image_row++;
    
                          //              if ($tmp_attributes_image_row > PRODUCTS_IMAGES_ATTRIBUTES_PER_ROW) {
                          if ($tmp_attributes_image_row > $products_options_names->fields['products_options_images_per_row']) {
                            $tmp_attributes_image .=  "\n";
                            $tmp_attributes_image_row = 1;
                          }
    
                          $tmp_attributes_image .= '<div class="attribImg">' . zen_image(DIR_WS_IMAGES . $products_options->fields['attributes_image']) . (PRODUCT_IMAGES_ATTRIBUTES_NAMES == '1' ? '<br />' . $products_options->fields['products_options_values_name'] : '') . '</div>' . "\n";
                        }
                      }
    Be sure to remove the "." before the "\n"; . If you forget that, the compiler won't run the page.

  2. #2
    Join Date
    Mar 2016
    Location
    Norcatur, Kansas, USA
    Posts
    80
    Plugin Contributions
    3

    Default Re: How to change product attribute image swatches to display side-by-side

    Okay, now I feel a little sheepish. I found a setting under the Option Names Manager to change this.

    In the Option Names Manager, click Edit for the option you want to modify. Down below is a setting called "Attribute Images per Row:". Change this to how many you want across and it does the same thing as my code edit.

  3. #3
    Join Date
    Aug 2005
    Location
    Arizona
    Posts
    27,761
    Plugin Contributions
    9

    Default Re: How to change product attribute image swatches to display side-by-side

    I found a setting under the Option Names Manager to change this.
    Hopefully, you have used the override system and your edited file is in a folder named for your template
    https://www.zen-cart.com/content.php...verride-system
    https://www.zen-cart.com/content.php...late-overrides

    Either way, you need to restore the original code by deleting the override file or replacing the edited core file
    Zen-Venom Get Bitten

  4. #4
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: How to change product attribute image swatches to display side-by-side

    Hopefully through reading those links will also see that you can/should establish your template in it's own unique folder structure rather than using the classic folder template override path. There are some hobbyist programmer benefits to it besides always having a clean copy of the original file. For example if you wanted to figure out if your change caused something or it is always that way you can swap between your version and the classic to see the difference. :) but as identified, not everything can be overriden, some things are either modified directly or something called an observer can be used to modify specific aspects.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  5. #5
    Join Date
    Feb 2007
    Location
    Ontario, Canada
    Posts
    234
    Plugin Contributions
    0

    Default Re: How to change product attribute image swatches to display side-by-side

    You may feel a little "Sheepish" but you just made my life easier because you posted what you did! I appreciate it!
    Thanks, Colleen
    www.af-company.com
    To err is human, but to really foul things up requires a computer. Farmers' Almanac, 1978

  6. #6
    Join Date
    Jan 2004
    Location
    N of San Antonio TX
    Posts
    9,144
    Plugin Contributions
    11

    Default Re: How to change product attribute image swatches to display side-by-side

    Also, check out adding an image to each Value of the dropdown. When the selection is made in the dropdown, the image will change with the selection.

    Select Vanilla Almond, Chocolate Fudge, and Sweet-n-Spicy at https://allpecans.com/index.php?main...roducts_id=133

 

 

Similar Threads

  1. All attributes are in a straight line, how to make it display side by side?
    By justwonder2 in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 2 Dec 2012, 10:39 PM
  2. Display product attributes in two columns (side by side)
    By DivaVocals in forum Templates, Stylesheets, Page Layout
    Replies: 72
    Last Post: 8 Nov 2010, 01:55 AM
  3. How to display 2 flash animations side by side?
    By toutou21 in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 20 Feb 2010, 02:57 PM
  4. How can i have the product info display on the right side of image?
    By missblover in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 22 Apr 2009, 09:16 PM
  5. How can I display attribute selections side by side? ie: date fields
    By aaelghat in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 23 Mar 2007, 06:56 PM

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