- Posts: 35
- Thank you received: 0
List current category in product listing
14 years 7 months ago #40917
by austio
List current category in product listing was created by austio
I am trying to list the current category that the product is in under the Product title in the product details view (product/show.php).
My products are in a parent category, as well as child category, but it only needs to show the child category that is is located in.
My products are in a parent category, as well as child category, but it only needs to show the child category that is is located in.
Please Log in or Create an account to join the conversation.
14 years 7 months ago #41054
by nicolas
Replied by nicolas on topic Re: List current category in product listing
You would first have to run a query to know the category name of the product and then display it.
But if you don't mind having the parent category name too, you could simply use the breadcrumb module of joomla. That would display the categories of the product automatically.
But if you don't mind having the parent category name too, you could simply use the breadcrumb module of joomla. That would display the categories of the product automatically.
Please Log in or Create an account to join the conversation.
14 years 7 months ago #41748
by austio
Replied by austio on topic Re: List current category in product listing
What bit of query code gets me the child category of the product? That would be preferred over the breadcrumb mod becuase if you find the item via its parent category (has all sub elements shown), the breadcrumb doesn't show the child cat that the item item is in, and that is really what I want to list.
Please Log in or Create an account to join the conversation.
14 years 7 months ago #41874
by nicolas
Replied by nicolas on topic Re: List current category in product listing
You can do like that:
Code:
$category = reset($this->categories);
echo $category->category_name;
The following user(s) said Thank You: austio
Please Log in or Create an account to join the conversation.
14 years 7 months ago #41934
by austio
Replied by austio on topic SOLVED - List current category in product listing
Thanks! Your code did exactly what I wanted! I discovered I didn't need to have items in both the parent category and a child category with "all sub elements" shown option, which is another plus!
Please Log in or Create an account to join the conversation.
Time to create page: 0.169 seconds