Author Topic: How to get parent_id of category in categories.php?  (Read 6596 times)

0 Members and 1 Guest are viewing this topic.

Offline pietg

  • Jr. Member
  • **
  • Posts: 86
    • View Profile
    • http://www.totaaldigitaal.nl
How to get parent_id of category in categories.php?
« on: February 05, 2003, 04:47:10 PM »
At the moment I am trying to restyle categories.php a little bit.

Part of it is the following code:
Code: [Select]
$categories2 = get_categories($cat_id);
$site_template->register_vars("categories2", $categories2);
unset($categories2);


I am searching for a way to fill the $cat_id in this code with the value of the cat_parent_id of the category

Example:
cat_id 1 = category A: Soccer Game  
cat_id 2 = subcategorie 1: Team 1 (cat_parent_id 1)  
cat_id 3 = subcategorie 2: Team 2 (cat_parent_id 1)
cat_id 4 = subcategorie 3: Team 3 (cat_parent_id 1)

So if people are in the cat_id 2, I would like to fill $cat_id with value "1".

Does somebody know how to do this?

kind regards,
Piet

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
How to get parent_id of category in categories.php?
« Reply #1 on: February 05, 2003, 11:21:35 PM »
if u want find out parent category ID, use this:
Code: [Select]
$cat_cache[$cat_id]['cat_parent_id']
if u also need NAME of parent category, use this:
Code: [Select]
$cat_cache[$cat_cache[$cat_id]['cat_parent_id']]['cat_name']
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline pietg

  • Jr. Member
  • **
  • Posts: 86
    • View Profile
    • http://www.totaaldigitaal.nl
How to get parent_id of category in categories.php?
« Reply #2 on: February 06, 2003, 04:26:36 PM »
Thanks you very much.

It worked together with some extra modification in function.php.

If somebody now browses to a subcategory he/she can see the "above" categories in the left colum.

Thanks again.

Piet

Offline DigitalOldschool

  • Newbie
  • *
  • Posts: 28
    • View Profile
Re: How to get parent_id of category in categories.php?
« Reply #3 on: April 13, 2005, 04:58:14 PM »
Hi.

I know this is an old post, but does anyone know what I need to do to get this to work?

Thanks for your help.

-DigitalOldschool