Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15
  1. #11
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: defining product listing default sort order in default_filter.php, faulty iterati

    More study about PHP "break" shows that only operates in for/while/switch type structures, not if() structures, but it is not unequivocally clear whether a break inside an if will operate on the for outside it.
    But yet, it moves...

  2. #12
    Join Date
    Jan 2007
    Location
    Australia
    Posts
    6,167
    Plugin Contributions
    7

    Default Re: defining product listing default sort order in default_filter.php, faulty iterati

    Quote Originally Posted by gjh42 View Post
    More study about PHP "break" shows that only operates in for/while/switch type structures, not if() structures, but it is not unequivocally clear whether a break inside an if will operate on the for outside it.
    But yet, it moves...
    How would you place a 'break' inside an 'if' anyway?

    if ($a == 1) {
    dosomething;
    break ;
    } else {
    dosomethingelse;
    break ;
    }

    Clearly, there is nothing to break out of here.

    if ($a == 1) {
    dosomething;
    break ;
    dosometyhingelse ;
    }

    That may work, sort of, but even if it did, it is clearly a pointless thing to do, the 'dosometyhingelse' will never be invoked.

    What other possible scenarios are there?
    -------------------------------------
    for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {
    if (isset(
    $column_list[$i]) && $column_list[$i] == 'PRODUCT_LIST_NAME') {
    $_GET['sort'] = $i+1 . 'a';
    $listing_sql .= " order by p.products_sort_order, pd.products_name";
    break;
    } else {
    $listing_sql .= " order by p.products_sort_order, pd.products_name";
    break;
    }
    }
    -------------------------------------

    Just for grins, I've stepped through this code and torvista is correct, this code only checks the first column defined, not all of them.

    Cheers
    Rod


  3. #13
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: defining product listing default sort order in default_filter.php, faulty iterati

    That code only runs if the setting is:

    1 Blank

    2 Invalid choice

    to set up a valid order by for:
    Code:
              $listing_sql .= " order by p.products_sort_order, pd.products_name";
    The IF allows for an invalid setting to be used on the ELSE portion that may be wanted that goes beyond the normal settings such as if you wanted a method for products_date_added and set to 5a (an invalid choice if only 4 columns are defined) by using:
    Code:
            } else {
    echo 'ELSE ' . '<br>';        	
    // sort by products_sort_order when PRODUCT_LISTING_DEFAULT_SORT_ORDER is left blank
    // for reverse, descending order use:
    //       $listing_sql .= " order by p.products_sort_order desc, pd.products_name";
    //          $listing_sql .= " order by p.products_sort_order, pd.products_name";
              $listing_sql .= " order by p.products_date_added, pd.products_name";
              break;
            }
    While not eloquent ... it makes the change easier to change on the default display order for the listing ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  4. #14
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: defining product listing default sort order in default_filter.php, faulty iterati

    To summarize ...
    Quote Originally Posted by torvista View Post
    1) Question
    Why is this limited to three when as far as I can see, the code deals only with two characters eg 2a?
    Correct. At the present time the code only deals with two characters.
    But, harmless.
    Quote Originally Posted by torvista View Post
    2a)
    $_GET['sort'] contains characters not 1-8 or a or d ( Question: Why are column numbers 1-8 allowed when there are only 7 options?)
    Actually, it should probably be expanded to allow for 0-thru-9.

    Quote Originally Posted by torvista View Post
    2b) Bug? : However the else clause has a break too, so this loop will only ever execute once and never identify the Product Name column unless it is the first column.
    Ya, probably a bug.
    Yet, it appears Ajeh has posted about a curious beneficial side-effect which can utilize this for positive results.

    Quote Originally Posted by torvista View Post
    3) Question about "20a"
    I cannot find where the second digit “0” is taken any account of…is this a typo and should be “2a”?
    Indeed, in the case of "20a", the "0a" has no effect, and is essentially ignored, since it is neither "a" nor "d", and thus the current code uses other defaults.
    Changing it to "2a" doesn't necessarily accomplish the desired end result either, depending what your desired end result is.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  5. #15
    Join Date
    Aug 2007
    Location
    Gijón, Asturias, Spain
    Posts
    2,586
    Plugin Contributions
    30

    Default Re: defining product listing default sort order in default_filter.php, faulty iterati

    ok, thanks for the confirmations.
    This all came about while trying to understand the default sorting mechanisms...
    Steve
    github.com/torvista: Spanish Language Pack, Google reCaptcha, Structured Data, Multiple Copy-Move-Delete, Image Checker, BackupMySQL Admin/Auto...

 

 
Page 2 of 2 FirstFirst 12

Similar Threads

  1. Product Listing Default Sort Order
    By mordechai in forum Basic Configuration
    Replies: 85
    Last Post: 13 Aug 2020, 11:32 AM
  2. All Listing - default sort order
    By only777 in forum General Questions
    Replies: 0
    Last Post: 3 Jul 2009, 08:57 PM
  3. Display Product Listing Default Sort Order
    By SMps in forum General Questions
    Replies: 2
    Last Post: 17 Jan 2009, 08:08 AM
  4. Display Product Listing Default Sort Order
    By Website Rob in forum Setting Up Categories, Products, Attributes
    Replies: 17
    Last Post: 13 Oct 2008, 04:12 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