Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2012
    Posts
    15
    Plugin Contributions
    0

    Default how to get the subcategories linkage or ID by built in function?

    Hi All,

    I want to create a drop down menu for all subcategories of the current category. And I tried to get the subcategory IDs by the following:

    $sub_current_ids=array();
    zen_get_subcategories($sub_current_ids,$current_category_id);

    However, the $sub_current_ids() only return the string "array"...

    What I am missing or doing wrong? Or is there any zen-cart function can get the linkage of all categories of the current category?

    Thanks and please help.

    Keith

  2. #2
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,472
    Plugin Contributions
    88

    Default Re: how to get the subcategories linkage or ID by built in function?

    The function needs the array to be passed by reference:
    Code:
    $sub_current_ids=array();
    zen_get_subcategories(&$sub_current_ids,$current_category_id);

  3. #3
    Join Date
    Apr 2012
    Posts
    15
    Plugin Contributions
    0

    Default Re: how to get the subcategories linkage or ID by built in function?

    lat9, Thank you very much!

    Now I can get all subcategories IDs and path by the following code:

    $sub_current_ids=array();
    zen_get_subcategories(&$sub_current_ids, $current_category_id);
    $count = count($sub_current_ids);

    For ($i=0; $i < $count; $i++)
    {
    $x = 'cPath=' . $current_category_id . '_' . $sub_current_ids[$i];
    echo zen_href_link('index', $x) . '<br>';
    }


    And the query is in the numberic sort order by IDs:

    array[0] http://localhost/loafer/index.php?ma...dex&cPath=23_1
    array[1] http://localhost/loafer/index.php?ma...dex&cPath=23_2
    array[2] http://localhost/loafer/index.php?ma...dex&cPath=23_3
    array[3] http://localhost/loafer/index.php?ma...ex&cPath=23_25
    array[4] http://localhost/loafer/index.php?ma...ex&cPath=23_27

    How can I make the query in the "correct" sort order? Just like the sort order of category sidebox or site map?

    I have been studied in functions_categories.php but don't know what to do next...

    $categories_query = "select c.categories_id, cd.categories_name, c.categories_status
    from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
    where " . $zc_status . "
    parent_id = '" . (int)$parent_id . "'
    and c.categories_id = cd.categories_id
    and cd.language_id = '" . (int)$_SESSION['languages_id'] . "'
    order by sort_order, cd.categories_name";

    Can anyone help?

    Thanks!

  4. #4
    Join Date
    Apr 2012
    Posts
    15
    Plugin Contributions
    0

    Default Re: how to get the subcategories linkage or ID by built in function?

    Can anyone give me some hints how to do this?

 

 

Similar Threads

  1. v139h Button with some programming built in (function)
    By swdynamic in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 30 May 2013, 03:54 PM
  2. Under SubCategories Images how do I get rid of Text/
    By neal41835 in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 8 Mar 2010, 03:55 AM
  3. how to get subcategories to show with image links?
    By bubbas454 in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 11 Feb 2010, 03:23 AM
  4. How do I get subcategories to show?
    By CindyM22 in forum Basic Configuration
    Replies: 5
    Last Post: 29 Jul 2009, 04:19 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