Keyword

make a k2 item url to sef url

  • George Nasis
  • George Nasis's Avatar Topic Author
  • Offline
  • Elite Member
More
9 years 11 months ago - 9 years 11 months ago #132952 by George Nasis
make a k2 item url to sef url was created by George Nasis
hallo there,

i want to achive somthing but don`t know how.
i make a query in which i take the k2 item url but in this format:
www.example.com/categoryA/categoryB/test where it ibelongs

but disabling sef i see that the item`s url is

/index.php?option=com_k2&view=item&id=63:autocad-2014&Itemid=334

so i am wondering maybe i miss something..i see after the item a Itemid is added and it takes =344bu
maybe it is the category?but 334 is surely not the category`s id..

thank you

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
9 years 11 months ago #132953 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: make a k2 item url to sef url
The Itemid (334) is the menu item's ID.

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

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

  • George Nasis
  • George Nasis's Avatar Topic Author
  • Offline
  • Elite Member
More
9 years 11 months ago - 9 years 11 months ago #132954 by George Nasis
Replied by George Nasis on topic Re: make a k2 item url to sef url
aha, thank you Krikor..

in which table is that???i am asking in order to change my query and add the itemID. and is it possible to achieve that?i mean how gonna combine the k2 item i retrieve to point the specific itemID of joomla menu?

thank you!

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
9 years 11 months ago #132955 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: make a k2 item url to sef url
The itemID is the id of the menu item the item (or category) belongs to.
The xx_menu contains the menu item's ID and the element that it is pointing to.

What are you trying to build ?

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

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

  • George Nasis
  • George Nasis's Avatar Topic Author
  • Offline
  • Elite Member
More
9 years 11 months ago - 9 years 11 months ago #132956 by George Nasis
Replied by George Nasis on topic Re: make a k2 item url to sef url
hallo krikor,
thanks for your interest!

i have this query
www.example.com/component/k2/item/testitem

so i want to change the href to the right one with the menuitem that you already said. i just found that on the table xxxx_menu. so i need to change my query to retrieve also the menuid?
Log in  or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
9 years 11 months ago #132957 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: make a k2 item url to sef url
Yes you should look up the table to find of there is a menu item assigned to that item's category.

Without this, you will not get the proper modules in your view.

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

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

  • George Nasis
  • George Nasis's Avatar Topic Author
  • Offline
  • Elite Member
More
9 years 11 months ago #132958 by George Nasis
Replied by George Nasis on topic Re: make a k2 item url to sef url
hallo krikor,

it is not about modules but about items. how will i get the right Itemid of the relevant k2 item?

for example in the k2 items table the k2 item id is 270 what i retrieve with the query.
in the menu table the itemid is 480. HOW am i supposed to make the query to retrieve the right item?which points to the right k2 item?

thank you

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

More
9 years 11 months ago #132959 by Lefteris
Replied by Lefteris on topic Re: make a k2 item url to sef url
@George Nasis

In order to get the correct route for an item you need to call the K2 route helper:
<?php
require_once JPATH_SITE.'/components/com_k2/helpers/route.php';
$item->link  = K2HelperRoute::getItemRoute($item->id.':'.$item->alias, $item->catid);
?>
As you can see you also need the item id, the item alias and the item category id.

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

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

  • George Nasis
  • George Nasis's Avatar Topic Author
  • Offline
  • Elite Member
More
9 years 11 months ago #132960 by George Nasis
Replied by George Nasis on topic Re: make a k2 item url to sef url
hallo lefteris,

thank you for your response.

so with this one i imagine that my query will concern only k2 items table and no need for the menu table.

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

More
9 years 11 months ago #132961 by Lefteris
Replied by Lefteris on topic Re: make a k2 item url to sef url
Yes, exactly. The helper will do the job finding the appropriate menu item id.

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

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