Page 1 of 2 12 LastLast
Results 1 to 10 of 16
  1. #1
    Join Date
    Dec 2010
    Posts
    257
    Plugin Contributions
    0

    Default How Can I Specify The Sort Order In The "Featured" Sidebar?

    I'd like to add a "Featured" sidebar to one of the sites I'm working on, but there doesn't seem to be a way to specify the order of the items within it. I want one of them to always stay on the top. The other three, below it, will be changed periodically. Is there a way to do this? Thanks!!

  2. #2
    Join Date
    Aug 2009
    Location
    Bedford, England
    Posts
    966
    Plugin Contributions
    0

    Default Re: How Can I Specify The Sort Order In The "Featured" Sidebar?

    What do you want to sort by?
    Phil Rogers
    A problem shared is a problem solved.

  3. #3
    Join Date
    Dec 2010
    Posts
    257
    Plugin Contributions
    0

    Default Re: How Can I Specify The Sort Order In The "Featured" Sidebar?

    As I said above, I want one listing always to be there, and the three below it to change when I decide to specify new "featured" items. :-) I don't care what order the three show up in, but I want the one to always be on top.

  4. #4
    Join Date
    Aug 2009
    Location
    Bedford, England
    Posts
    966
    Plugin Contributions
    0

    Default Re: How Can I Specify The Sort Order In The "Featured" Sidebar?

    Two ways I can think of, you could either hard code the product you want on top into the side box code, then exclude it from the db query.
    Or
    Maybe implement something similar to this which by chance is a similar thing I posted earlier today!!
    http://www.zen-cart.com/showthread.p...Filter-Sidebox

    So instead of specifying more than one product to display at the top you would just specify the one you want.

    Obviously you need to use this as a guide how to implement on your particular sidebox but logic would be the same.

    Backup before you try anything and create a template override file when implementing.
    Phil Rogers
    A problem shared is a problem solved.

  5. #5
    Join Date
    Dec 2010
    Posts
    257
    Plugin Contributions
    0

    Default Re: How Can I Specify The Sort Order In The "Featured" Sidebar?

    As I haven't got a clue how to do either, which would be easier for a total php-moron? LOL

  6. #6
    Join Date
    Aug 2009
    Location
    Bedford, England
    Posts
    966
    Plugin Contributions
    0

    Default Re: How Can I Specify The Sort Order In The "Featured" Sidebar?

    Ah ok haha, well, actually having thought about it I doubt my option 2 for you will work because your featured side box is probably either selecting random entries and in which case the one you want to show might not be in the output or it might be ordering by rand in which case changing the order to my example means that "other" featured products probably won't get shown.

    So.. Option 1 is the way to do it.

    If you haven't a clue I don't mind giving you the code but I'm not logged on now so ill subscribe to this thread as a reminder to come back tomorrow to do it for you.

    If you haven't heard from me either pm me or just post again to remind me ;-)
    Phil Rogers
    A problem shared is a problem solved.

  7. #7
    Join Date
    Dec 2010
    Posts
    257
    Plugin Contributions
    0

    Default Re: How Can I Specify The Sort Order In The "Featured" Sidebar?

    Okay, thanks. I appreciate it!

    I actually have specified the four entries that I want listed in the Featured box. The curious thing is that while they show up on the Admin/Catalog/Featured Products listing in alphabetical order, they don't show up that way on the actual site. The one that I want to be on top is always on the very bottom, no matter which other books I select. And they don't appear to be showing up in random order, because they're always in the same order no matter how often I refresh the pages.

    I sure do appreciate any advice you can offer me, because I've been fighting with this most of the afternoon, and reading through dozens of forum posts, but I haven't yet found any solutions.

    I guess, for the meantime, I could just delete the other three items, and only have the one under Featured.......... :-)
    Last edited by Scully; 12 Feb 2013 at 11:33 PM.

  8. #8
    Join Date
    Aug 2009
    Location
    Bedford, England
    Posts
    966
    Plugin Contributions
    0

    Default Re: How Can I Specify The Sort Order In The "Featured" Sidebar?

    It'll all be apparent when I check the code calling the items being shown dont worry we'll get it to work ;-)
    Phil Rogers
    A problem shared is a problem solved.

  9. #9
    Join Date
    Aug 2009
    Location
    Bedford, England
    Posts
    966
    Plugin Contributions
    0

    Default Re: How Can I Specify The Sort Order In The "Featured" Sidebar?

    Right written up a solution for you, give it a go and let me know how you get on.. BACKUP BACKUP BACKUP..


    Ok so create a template version of your
    includes/modules/sideboxes/featured.php


    and put it:
    includes/modules/sideboxes/YOUR_TEMPLATE/featured.php


    find:

    PHP Code:
    $random_featured_products_query "select p.products_id, p.products_image, pd.products_name,
                                           p.master_categories_id
                               from (" 
    TABLE_PRODUCTS " p
                               left join " 
    TABLE_FEATURED " f on p.products_id = f.products_id
                               left join " 
    TABLE_PRODUCTS_DESCRIPTION " pd on p.products_id = pd.products_id )
                               where p.products_id = f.products_id
                               and p.products_id = pd.products_id
                               and p.products_status = 1
                               and f.status = 1
                               and pd.language_id = '" 
    . (int)$_SESSION['languages_id'] . "'"

    and change to:

    PHP Code:
    $random_featured_products_query "select p.products_id, p.products_image, pd.products_name,
                                           p.master_categories_id
                               from (" 
    TABLE_PRODUCTS " p
                               left join " 
    TABLE_FEATURED " f on p.products_id = f.products_id
                               left join " 
    TABLE_PRODUCTS_DESCRIPTION " pd on p.products_id = pd.products_id )
                               where p.products_id = f.products_id
                               and p.products_id = pd.products_id
                    and p.products_id != 100
                               and p.products_status = 1
                               and f.status = 1
                               and pd.language_id = '" 
    . (int)$_SESSION['languages_id'] . "'"

    notice we added this line:

    and p.products_id != 100
    you need to change the “100” to the products_id of the product you want at the top. So putting this here we are stopping it from being called into the standard loop. before you go further, check that it has now stopped that product from showing in the box.

    Then we need to hard code in above where the rest of the results are outputted.

    So then create a copy/ template override of:
    includes/templates/template_default/sideboxes/tpl_featured.php

    and locate it:
    includes/templates/YOUR_TEMPLATE/sideboxes/tpl_featured.php


    then find this:
    PHP Code:
    $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_WIDTHSMALL_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"

    And change to this, NOTE! you need to change the values as specified below where commented:
    PHP Code:
    $content "";
      
    $content .= '<div class="sideBoxContent centeredContent">';
    //
    //added to hard code one to always show at the top
    //
    //values that need to be replaced:
    //100 – needs to be changed to your product id. It is referred to three times
    //200 – needs to be changed to the above products master category id appears once.
    //productsimage.jpg need to change to the image file name for the product referred to once.
    //Products Name Here needs to change to the actual products name reffered to twice.
    $featured_box_price zen_get_products_display_price(100);
        
    $content .= "\n" '  <div class="sideBoxContentItem">';
        
    $content .=  '<a href="' zen_href_link(zen_get_info_page(100), 'cPath=' zen_get_generated_category_path_rev(200) . '&products_id=100">' zen_image(DIR_WS_IMAGES 'productsimage.jpg''Products Name Here'SMALL_IMAGE_WIDTHSMALL_IMAGE_HEIGHT);
        
    $content .= '<br />Products Name Here</a>';
        
    $content .= '<div>' $featured_box_price '</div>';
        
    $content .= '</div>';
    // 
    // end hard code product
    //
    //
      
    $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_WIDTHSMALL_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"
    this solution is obvioisly hard coded and is no way dynamic, so at anytime you want that product changed you will have to manually change the values specified. Also more importanly, if that product ever seases to exist the code will most likey break, in which case you will need to revert back/remove the hard coded part of the code.

    hope this work.. not tested but should work, in theory..
    Phil Rogers
    A problem shared is a problem solved.

  10. #10
    Join Date
    Dec 2010
    Posts
    257
    Plugin Contributions
    0

    Default Re: How Can I Specify The Sort Order In The "Featured" Sidebar?

    GULP!!! I am SO not any good with PHP!

    Okay, I'm doing a full system backup now...then I'll pull out the machete and start hacking my way through...whatever it is you sent me. LOL If I have any questions, you can be sure I'll ask!

    THANK YOU, regardless of how it comes out, for taking the time and effort to help me!

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. v151 Where is the code for the product listing sort "up" and "down' arrow?
    By rcrosier in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 30 Jan 2013, 06:38 PM
  2. v139h Can I edit the name of a link under the "Categories" sidebar?
    By CasperPS in forum Setting Up Categories, Products, Attributes
    Replies: 1
    Last Post: 10 Apr 2012, 10:52 AM
  3. How can I change the "Order Number" counter?
    By mkalavitz in forum General Questions
    Replies: 3
    Last Post: 10 Feb 2010, 06:00 AM
  4. can you control the sort order of the featured products on the front page
    By George Susini in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 18 Apr 2009, 08:05 PM
  5. How can I add options to the order "Status" list?
    By BruceWChenoweth in forum General Questions
    Replies: 2
    Last Post: 18 Feb 2009, 09:23 PM

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