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 » Mon Feb 13, 2017 4:12 pm

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: 14371
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: Category parent name

Post by Thorsten » Tue Feb 14, 2017 8:20 pm

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 » Mon Feb 27, 2017 11:37 am

Thanks, Thorsten.

But will I have an opportunity to get the real name of the category? Not just the ID.

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

Re: Category parent name

Post by Thorsten » Tue Feb 28, 2017 7:42 pm

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

Who is online

Users browsing this forum: No registered users and 1 guest