Category parent name

In this board you can talk about general questions about phpMyFAQ

Moderator: Thorsten

Post Reply
roschi
Posts: 9
Joined: Mon Nov 14, 2016 12:02 pm

Category parent name

Post by roschi »

Hi Thorsten,

any possibility to get the category parent name easily?

At the moment I'm just getting the immediate (sub)category name of an article by:

$currentCategory = PMF_Filter::filterInput(INPUT_GET, 'cat', FILTER_VALIDATE_INT);
$mytitle = $category->categoryName[$currentCategory]['name'];

Thanks!
Thorsten
Posts: 15560
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: Category parent name

Post by Thorsten »

Hi,

you can get the parent ID by using

Code: Select all

$parentId = $category->categoryName[$currentCategory]['parent_id'];
bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
roschi
Posts: 9
Joined: Mon Nov 14, 2016 12:02 pm

Re: Category parent name

Post by roschi »

Thanks, Thorsten.

But will I have an opportunity to get the real name of the category? Not just the ID.
Thorsten
Posts: 15560
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: Category parent name

Post by Thorsten »

Hi,

sure:

Code: Select all

$parentId = $category->categoryName[$currentCategory]['parent_id'];
$categoryData = $category->getCategoryData($parentId);
$categoryName = $categoryData->getName();
bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
Post Reply