Keyword

[Solved] Display K2 Category Title in Joomla Template index.php File?

  • Justin Herrin
  • Justin Herrin's Avatar Topic Author
  • Offline
  • Junior Member
More
14 years 2 months ago #85853 by Justin Herrin
Hello everyone,Just wondering if anyone has come across a snippet of code that would enable you to display the current item's K2 Category (or Parent Category) Title in your custom Joomla template's index.php, somewhere outside of the component area.I have searched here and Google, but have not found anything about it. I have also tried the following PHP codes with no success...<?php echo $this->item->category->name; ?><?php echo $this->category->name; ?><?php echo $this->item->categoryname; ?>Again, I'm looking to have the Category Title display outside of the component area in a separate area of the template.Unfortunately I can not provide a link, as the development server is behind a firewall.Any assistance or tips would be very much appreciated.Thanks in advance!

Please Log in or Create an account to join the conversation.

  • Justin Herrin
  • Justin Herrin's Avatar Topic Author
  • Offline
  • Junior Member
More
14 years 2 months ago #85854 by Justin Herrin
Well after trying some more code snippets with no luck, I made a module based off of the mod_k2_tools module to achieve what the project needs.

Added "[Solved]" to the topic title.

Please Log in or Create an account to join the conversation.

More
14 years 1 month ago #85855 by william white
How did you get the module and the item displaying to sync?
Can you share the module with the community?

Please Log in or Create an account to join the conversation.

  • Justin Herrin
  • Justin Herrin's Avatar Topic Author
  • Offline
  • Junior Member
More
14 years 1 month ago #85856 by Justin Herrin
I utilized the mod_k2_tools module's Breadcrumbs feature as a basis for this. I basically just made the last linked item in the breadcrumb trail be displayed in the custom module.

It's hard to explain, so hopefully this will help...

When my breadcrumb looks like this: Home > Locations > USA > California (I am viewing the California category)
The module will display: USA

When my breadcrumb looks like this: Home > Locations > USA > California > Lake Tahoe (I am viewing the Lake Tahoe item)
The module will display: California

The module does need some more work because when I am viewing the Locations category, I see nothing, because there is no breadcrumb link before Locations. So in that case I am hoping to add a If statement that will display a default title instead of nothing at all. So hopefully...

When my breadcrumb looks like this: Home > Locations (I am viewing the Locations category)
The module will display: My website's title or other default title that I set.


Sorry if this sounds confusing.

Once I complete the other coding on the module, I can share it with the community :)

Please Log in or Create an account to join the conversation.

More
14 years 1 month ago #85857 by william white
Ok, thanks, i see you didnt have to sync at all...smart thinking!

Please Log in or Create an account to join the conversation.

More
13 years 10 months ago #85858 by Chris Gornall
Hi, Have you got any further on the development of this module?

It's exactly what I'm looking to do.

Thanks.

Please Log in or Create an account to join the conversation.

  • Justin Herrin
  • Justin Herrin's Avatar Topic Author
  • Offline
  • Junior Member
More
13 years 10 months ago #85859 by Justin Herrin
Hello Chris, yes I have the module finished to my site's needs. It functions well for what we need. When I get to the office tomorrow or Friday I will package things together and share here.

Please Log in or Create an account to join the conversation.

More
13 years 10 months ago #85860 by Chris Gornall
That'd be great.

so far I have been using this call:
< ?php echo $this->title; ?>
to return the current item title, I'm sure there must be a really quick call to get the category title too.

I'm looking forward to seeing how you've done it.

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum