Page 4 of 5 FirstFirst ... 2345 LastLast
Results 31 to 40 of 45
  1. #31
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: How to make clicking a category display all its items under the category name??

    Categories Dressing has some fairly complex logic to determine and apply correct <ul> nesting; the stock tpl_categories code (largely shared by category list box) does not inherently give any such information. All items are identical in hierarchical structure, only given some basic top/sub/selected classes. That is why I added the different $div_class tags, to at least determine what kind of link it is. There is no simple way to dynamically group products under a specific category.

    The styles do not apply to the links because there are already rules for generic links, and you did not include the link element in your rules.
    .category-parent-selected a, .category-product-selected a {color: #ff0000;}
    will apply the color to the links (and not to the separators).

    This test
    (($current_category_id!=0)&&($box_categories_array[$i]['category_id']==$current_category_id))
    is supposed to exclude the case where no category is selected (home or non-cat/prod pages), but it apparently is not functioning correctly. Can you add a debug line
    echo ' current-cat:'.$current_category_id.' processing-cat:'.$box_categories_array[$i]['category_id']."\n";//debug
    in your debug area?
    Then see what it says for differeny kinds of pages.

  2. #32
    Join Date
    Dec 2003
    Location
    UPstate NY
    Posts
    440
    Plugin Contributions
    0

    Default Re: How to make clicking a category display all its items under the category name??

    applied your requested debug code :)

    output upon clicking first category with four products:
    current-cat:1 processing-cat:1 current-cat:1 processing-cat: current-cat:1 processing-cat: current-cat:1 processing-cat: current-cat:1 processing-cat: current-cat:1 processing-cat:2 current-cat:1 processing-cat: current-cat:1 processing-cat:4 current-cat:1 processing-cat:3

    output upon clicking one of the products within the first category with four products:

    current-cat:0 processing-cat:1 current-cat:0 processing-cat: current-cat:0 processing-cat: current-cat:0 processing-cat: current-cat:0 processing-cat: current-cat:0 processing-cat:2 current-cat:0 processing-cat: current-cat:0 processing-cat:4 current-cat:0 processing-cat:3

    output upon clicking third category which has no products: (yes, third category is ID #4)

    current-cat:4 processing-cat:1 current-cat:4 processing-cat: current-cat:4 processing-cat: current-cat:4 processing-cat: current-cat:4 processing-cat: current-cat:4 processing-cat:2 current-cat:4 processing-cat: current-cat:4 processing-cat:4 current-cat:4 processing-cat:3

    output upon clicking a non-prod non-cat page:

    current-cat:0 processing-cat:1 current-cat:0 processing-cat: current-cat:0 processing-cat: current-cat:0 processing-cat: current-cat:0 processing-cat: current-cat:0 processing-cat:2 current-cat:0 processing-cat: current-cat:0 processing-cat:4 current-cat:0 processing-cat:3

    debug code is placed immediately after the code which configures values for $div_class

    also...

    The styles do not apply to the links because there are already rules for generic links, and you did not include the link element in your rules.
    .category-parent-selected a, .category-product-selected a {color: #ff0000;}
    will apply the color to the links (and not to the separators).
    The styles do apply to the LINKS (A) -- they just don't apply "correctly" -- i.e. the example colors they should get if the if-then logic to assign $div_class values works "correctly" -- they don't apply to the LI tags surrounding the links.

    Logic we want (I think most people would want):

    If home page or non-product or non-category page, show no products for any category.
    If category page, show all active products for the category only.
    If product page, show all active products for the product's category only.

    Maybe there needs to be a preliminary test what kind page it is -- cat page?? prod page?? neither?? then do stuff based on this result...I just now realized we need a 'where product_status = active' test too, sigh...we should not include inactive items...

    Is that simple enough?? I hope so!!

    Do you have any suggestions for properly indenting the product names??
    I will work on this part...
    I have not yet tried using a <div> instead of a <span> around the LI tags...
    Or the A tag could have its left margin messed with LOL based on if the CSS style for products

    Thank you, Tom

  3. #33
    Join Date
    Dec 2003
    Location
    UPstate NY
    Posts
    440
    Plugin Contributions
    0

    Default Re: How to make clicking a category display all its items under the category name??

    Maybe an easier way to do the program logic is this:

    If the page is not a prod or cat page, output only category links, nothing else.

    If the page is a prod or cat page, output only the product links for that specific category below the category link per se, and for no other categories.
    Then we only need two css tags, one for the category, one for the products...

    Might be a little more complicated to write but the first case is easier now??

    Thank you, Tom

  4. #34
    Join Date
    Dec 2003
    Location
    UPstate NY
    Posts
    440
    Plugin Contributions
    0

    Default Re: How to make clicking a category display all its items under the category name??

    Doing the above could also be generalized to sub-categories too.

    Something in the code could have the *administrator* (person installing the addon) toggle whether to do subcats or products...

    Thank you, Tom

  5. #35
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: How to make clicking a category display all its items under the category name??

    output upon clicking one of the products within the first category with four products:

    current-cat:0 processing-cat:1
    This indicates that $current_category_id (a stock ZC variable) is null or 0 when you are on a product info page. There needs to be a different variable tested to get the category that holds the current product. The mod's original developer knew that $current_category_id didn't work (unless you are on a category page), but didn't figure out a substitute. In /includes/classes/category_list.php around line , find
    PHP Code:
                // this doesn't work :(
                
    if($category_id == $current_category_id){ 
    and replace with
    PHP Code:
                // this doesn't work :(
                //test gjh42 20130207
                
    $current_category_id_list $current_category_id$current_category_id: ($products_idzen_get_products_category_id($products_id): 0);
                if(
    $category_id == $current_category_id_list){ 
    This should allow $box_categories_array[$i]['current'] to be correctly set, and simplify handling in tpl_category_list.php. I'll look at that next. Meanwhile, you can add a debug line
    echo ' current='.$box_categories_array[$i]['current'];
    in your debug area to see how it works.

  6. #36
    Join Date
    Dec 2003
    Location
    UPstate NY
    Posts
    440
    Plugin Contributions
    0

    Default Re: How to make clicking a category display all its items under the category name??

    It works better with the added code...getting there.
    Give me a few moments to compile the results, please...
    Thank you, Tom

  7. #37
    Join Date
    Dec 2003
    Location
    UPstate NY
    Posts
    440
    Plugin Contributions
    0

    Default Re: How to make clicking a category display all its items under the category name??

    debug results after adding new code to /includes/classes/category_list.php
    I thought it improved things but now I do not think so
    More adjustment to the code logic??

    output upon clicking first category with four products:
    current-cat:1
    processing-cat:1
    current=
    current-cat:1
    processing-cat:
    current=
    current-cat:1
    processing-cat:
    current=
    current-cat:1
    processing-cat:
    current=
    current-cat:1
    processing-cat:
    current=
    current-cat:1
    processing-cat:2
    current=
    current-cat:1
    processing-cat:
    current=
    current-cat:1
    processing-cat:4
    current=
    current-cat:1
    processing-cat:3
    current=

    output upon clicking one of the products within the first category with four products:

    current-cat:1
    processing-cat:1
    current=
    current-cat:1
    processing-cat:
    current=
    current-cat:1
    processing-cat:
    current=
    current-cat:1
    processing-cat:
    current=
    current-cat:1
    processing-cat:
    current=
    current-cat:1
    processing-cat:2
    current=
    current-cat:1
    processing-cat:
    current=
    current-cat:1
    processing-cat:4
    current=
    current-cat:1
    processing-cat:3
    current=

    output upon clicking third category which has no products: (yes, third category is ID #4)

    current-cat:4
    processing-cat:1
    current=
    current-cat:4
    processing-cat:
    current=
    current-cat:4
    processing-cat:
    current=
    current-cat:4
    processing-cat:
    current=
    current-cat:4
    processing-cat:
    current=
    current-cat:4
    processing-cat:2
    current=
    current-cat:4
    processing-cat:
    current=
    current-cat:4
    processing-cat:4
    current=
    current-cat:4
    processing-cat:3
    current=

    output upon clicking a non-prod non-cat page:

    current-cat:0
    processing-cat:1
    current=
    current-cat:0
    processing-cat:
    current=
    current-cat:0
    processing-cat:
    current=
    current-cat:0
    processing-cat:
    current=
    current-cat:0
    processing-cat:
    current=
    current-cat:0
    processing-cat:2
    current=
    current-cat:0
    processing-cat:
    current=
    current-cat:0
    processing-cat:4
    current=
    current-cat:0
    processing-cat:3
    current=

    debug code is placed immediately after the code which configures values for $div_class

    What happens when clicking links:

    Click the home page header links:
    all cats = pink (wrong, should be green)
    all prods = yellow, should not appear, display: none not being used anywhere

    Click category link containing products:
    current cat name = purple (correct)
    current cat prods = pink (correct)
    other cats = green (correct)
    product under other cats = yellow, should not appear eventually

    Click any product link within category (becomes current category by default):
    current cat name = pink (wrong, should be purple)
    current cat prods = yellow (wrong, should be pink)
    other cats = pink (wrong, should be green)
    product under other cats = yellow, should not appear

    Click any category with NO products (edge case, will not happen):
    current cat name = purple (correct)
    current cat prods = NONE (correct)
    other cats = green (correct)
    product under other cats = yellow, should not appear eventually

    Click any other page link besides home page or cat/prod:
    all cats = pink (wrong, should be green)
    all prods = yellow, should not appear eventually

    Thank you, Tom

  8. #38
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: How to make clicking a category display all its items under the category name??

    Hmm... the test is still not getting the current cat. More debug may help explain where it's falling down:
    echo ' current='.$box_categories_array[$i]['current'].' prid:'.$products_id.' zgprcid:'.zen_get_products_category_id($products_id)."\n";

    Note that current= should give a value of true or false. False might be output as blank, which is what we see.
    Last edited by gjh42; 7 Feb 2013 at 09:47 PM.

  9. #39
    Join Date
    Dec 2003
    Location
    UPstate NY
    Posts
    440
    Plugin Contributions
    0

    Default Re: How to make clicking a category display all its items under the category name??

    debug results after adding new debug code

    home page opens: current-cat is 0, current, prid, zgprcid have no value
    click category: current-cat=category ID, current, prid, zgprcid have no value
    click a product: current-cat=category ID, current, prid, zgprcid have no value
    click a non-prod/cate page: current-cat is 0, current, prid, zgprcid have no value

    HTH

  10. #40
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: How to make clicking a category display all its items under the category name??

    That's just weird. On a product page, there should be a $products_id. The only thing I can think is that that variable hasn't been set yet when the class runs, though it only runs when called from the module file (well after header info is initialized).

    It turns out that there is no $products_id variable on the product info page. Instead, main_template_vars.php sets $products_id_current, so that is the variable to use in all relevant places.
    Another place where the original mod author messed up.


    Note that $_GET['products_id'] is always available on the product info page, and that is probably why the author assumed that $products_id was the right variable to use.
    Last edited by gjh42; 7 Feb 2013 at 11:05 PM.

 

 
Page 4 of 5 FirstFirst ... 2345 LastLast

Similar Threads

  1. v151 How to display the last category name
    By Kevin205 in forum General Questions
    Replies: 6
    Last Post: 30 Oct 2013, 04:11 AM
  2. How to link the category name under featured products
    By newbie456 in forum General Questions
    Replies: 0
    Last Post: 8 Sep 2011, 09:38 AM
  3. Replies: 3
    Last Post: 12 Jun 2011, 06:26 AM
  4. how to add the optiona name(text type) to all products under a category?
    By mybiz9999 in forum Setting Up Categories, Products, Attributes
    Replies: 3
    Last Post: 7 Aug 2010, 04:24 AM
  5. Displaying category name under new items thumbnails
    By aeolidia in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 20 Dec 2006, 12:05 AM

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