Keyword

Remove category alias from K2 item URL

More
8 years 7 months ago #151414 by JP
Hello,
I am using the K2 content module to display certain items on K2 category menu item pages. Items are assigned to either a category or a sub-category within the K2 component.
The following is happening:
- On pages that HAVE the K2 content module on them: An item's URL includes the sub-category (for example: website.com/index.php/category/sub-category/item/35-item-name
Having the sub-category in the URL shows the K2 content module on the item's detail page, which I don't want to happen. The K2 item that is generated by the menu item (separate from the module) should only show the details of the K2 item, and the module should not be on this page at all.

How can I remove the sub-category from the URL? In a category listing, I'd like the K2 item's URL to appear as: website.com/index.php/category/item/35-item-name so that nothing else besides the item display on the page. I've tested and this version of the URL displays correctly. How can I adjust the code to achieve this?

Thank you!

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 7 months ago #151420 by Krikor Boghossian
Replied by Krikor Boghossian on topic Remove category alias from K2 item URL
Hello JP,

Are these categories mapped into menu items?

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

More
8 years 7 months ago #151427 by JP
Hi Krikor,

Yes, each page is displayed using a K2 Categories menu item.

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 7 months ago #151435 by Krikor Boghossian
Replied by Krikor Boghossian on topic Remove category alias from K2 item URL
This module will not give you control over your modules.
If a category is not mapped into a Joomla! menu item, then it will be rendered with the current menu item. This means it will show the modules of the menu item you are browsing.

To avoid this behaviour, map each K2 category into a separate menu item to have ultimate control over your modules.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

More
8 years 7 months ago #151445 by JP
Hi Krikor,

I apologize if there was a miscommunication. All of the K2 categories are already currently mapped into individual menu items - for example, there is a site menu that displays all of the categories, each individual menu item uses 1 K2 category (also a K2 category menu item) to display the results of that category on the page. The K2 content module appears on some, but not all of these K2 category menu item pages. On the pages where the K2 content module does display, the module is displaying while in category view, but also K2 item view; so when a user clicks on a K2 item's title, it is showing the K2 content module in addition to the K2 item details. I'd like for this detailed or "drilled-down" K2 item view to not include the module. So the modules and the menu items are generated separately, and the item view should not include the module on the page. If it's useful to know, the modules are assigned to corresponding menu items, which are controlled by a K2 category menu item. I found that by removing the sub-category alias from the URL, I could achieve the detailed K2 item view without the module displaying, so I was hoping there was a way to achieve that.

Thanks

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 7 months ago #151473 by Krikor Boghossian
Replied by Krikor Boghossian on topic Remove category alias from K2 item URL
Got it,

The item, since it does not belong to a direct menu item it will always inherit its modules from it's parent menu item. In this case it's direct category.

There are two ways to change this behaviour.
a) Use an extension like Advanved module manager
b) Directly exclude these module positions when the view is an item from your template. Some coding is required, you can use this as a starting point:
github.com/kricore/Advanced-templating-with-K2/blob/master/_inc/cheatsheet.php#L24-L36

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

More
8 years 6 months ago #151848 by JP
Thanks, Krikor! Apologies for the delayed response. I ended up adding a sub-navigation item and displaying the category items in there. Then, I reassigned the K2 items to the parent category. Next, the module was assigned to the sub-category page, so now all of the items share a parent category and the module does not display on the detailed K2 item's page. Unfortunately, the scope of this project did not allow me to download NoNumber's Advanced Module Manager so I needed to find a different solution.

Thanks for your help!

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 6 months ago #151854 by Krikor Boghossian
Replied by Krikor Boghossian on topic Remove category alias from K2 item URL
It is impossible to fully understand the layout without seeing the site, the admin and menu structure, however I can give you some code to manually show/ hide a module when the view matches certain criteria.
For example you can show it only for an item, an item with a specific id, a menu item etc..

Take a look at this:
github.com/kricore/Advanced-templating-with-K2/blob/master/_inc/cheatsheet.php#L24-L46

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

More
8 years 6 months ago #151855 by JP
Very helpful, thank you!

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 6 months ago #151856 by Krikor Boghossian
Replied by Krikor Boghossian on topic Remove category alias from K2 item URL
You 're welcome :)

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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


Powered by Kunena Forum