Results 1 to 8 of 8
  1. #1
    Join Date
    Mar 2006
    Location
    Florence, Italy
    Posts
    153
    Plugin Contributions
    0

    help question Categories parent_id

    I'm working to build a function related to categories and I've a doubt.

    If the master category is 'MASTER'
    the subcategory is 'SUB'
    the subsubcategory i 'SUBSUB':

    the parent_id of MASTER is 0
    the parent_id of SUB is the categories_id of MASTER
    the parent_id of SUBSUB is the categories_id of SUB

    is this correct?

    Also, the master_categories_id of a product of SUBSUB is the categories_id of SUBSUB or of MASTER?

    Many thanks - Giovanni

  2. #2
    Join Date
    Apr 2006
    Location
    London, UK
    Posts
    10,569
    Plugin Contributions
    25

    Default Re: Categories parent_id

    No this isn't quite correct. It would be if there is only one level of categories. But it's not generally so.

    The master category is product-specific. Each product has one but they can be different.

    If a product is in a top level category then its master category's parent ID would indeed be zero (which really means doesn't have a parent). But if the product has master category 2 which is a subcategory of category 1, then the parent ID of of the master category would be 1 and not 0.

    This is further complicated by linked products, which allow a product to be in two or more categories at the same time. However, a product can only have one master category.

    I'm guessing that you may have more questions about this ... please feel free to ask them.
    Kuroi Web Design and Development | Twitter

    (Questions answered in the forum only - so that any forum member can benefit - not by personal message)

  3. #3
    Join Date
    Mar 2006
    Location
    Florence, Italy
    Posts
    153
    Plugin Contributions
    0

    Default Re: Categories parent_id

    well, kuroy
    I want to make some controls on categories, sub-categories and sub-sub-categories. For this I've modified the database and built a function for the control.

    In the category and subcategory I can control the situation. In includes\modules\mytemplate\category_row.php I've modified the code at row 31

    while (!$categories->EOF) {

    $cat_num = $categories->fields['categories_id'];
    $cat_vis = zen_control_categories_visibility ($cat_num);
    if (!$cat_vis) $categories->MoveNext();

    if (!$categories->fields['categories_image']..........

    The 3 statements that I've added (also in other scripts) works well for te categories and the sub-categories, but don't work for the sub-sub-categories and I'm not able to find where modify something!
    For this I've theese doubts!
    Any idea about the script to modify??

    Thanks - Giovanni

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

    Default Re: Categories parent_id

    Since zen_control_categories_visibility () is a custom function, it might help to see its code. The code you posted seems so straightforward that it is hard to imagine it being the source of the problem. What *is* the problem, anyway? This is apparently supposed to hide particular categories in certain circumstances??

  5. #5
    Join Date
    Mar 2006
    Location
    Florence, Italy
    Posts
    153
    Plugin Contributions
    0

    Default Re: Categories parent_id

    Yes.....
    I've added a field to the categories table to control the visibility (for resellers).
    the problem is that I'm not able to control the sub-sub-catebories when there's shown in the main page (clicking the sub-categories on the category box).
    In all the other situation the control is right.
    If you like I can post the function, but is not there the problem.
    Any idea???? - Thanks - Giovanni

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

    Default Re: Categories parent_id

    You may be confusing the code in this while loop.
    Perhaps instead of

    if (!$cat_vis) $categories->MoveNext();

    you should wrap the conditional around the rest of the while content so it skips to the MoveNext at the bottom:

    if ($cat_vis) {
    if (!$categories->fields['categories_image']..........
    ...
    }
    $categories->MoveNext();

    I don't know if this is related to your problem, but it seems like it could cause some kind of misbehavior.

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

    Default Re: Categories parent_id

    I've figured out what was bugging me about that code:
    You have a while loop that is supposed to stop at the last category in the array, but you will increment the count twice when you skip a category. If it was processing the last category in the array and skips it, it will proceed to try to process the last + 1, which doesn't exist.
    This may not cause a fatal error, but it sounds like it could cause some incorrect output.

  8. #8
    Join Date
    Mar 2006
    Location
    Florence, Italy
    Posts
    153
    Plugin Contributions
    0

    Default Re: Categories parent_id

    Many thanks, gjh42
    this was the problem, and is happened because perhaps I'm too tired!!!
    Now all is going perfectly - Many thanks again - Giovanni

 

 

Similar Threads

  1. 1054 Unknown column 'c.parent_id' in 'on clause'
    By darocket in forum General Questions
    Replies: 9
    Last Post: 21 Jul 2010, 03:56 AM
  2. Using SQL to remove parent_id from sub-categories
    By ---kate--- in forum General Questions
    Replies: 0
    Last Post: 30 Mar 2009, 11:19 AM
  3. 1054 Unknown column 'c.parent_id' in 'on clause'
    By kimsonvu in forum General Questions
    Replies: 1
    Last Post: 21 Dec 2007, 06:12 PM
  4. 1054 Unknown column 'c.parent_id' in 'on clause'
    By linkedla in forum General Questions
    Replies: 2
    Last Post: 28 Aug 2007, 02:37 PM
  5. Check category_id to parent_id
    By numinix in forum Contribution-Writing Guidelines
    Replies: 5
    Last Post: 9 Jul 2007, 07:47 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