How to change category URL in router.php

  • Posts: 3
  • Thank you received: 0
9 years 6 months ago #231536

-- Joomla version -- : 3.4.1
-- PHP version -- : 2.6.1

Hello,

I would like to know how can I change the URL from

www.example.com/hikashop-menu-for-module...ory/my-category-name

to

www.example.com/my-category-name

I tried to leave blank the menu alias of Joomla and leave blank the SEF category name in Hikashop as well, but it doesn't work. I think the best thing is to modify the router.php file. Could you tell me how?

thanks in advance

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

  • Posts: 84307
  • Thank you received: 13701
  • MODERATOR
9 years 6 months ago #231569

Hi,

The part hikashop-menu-for-module-123 is the alias of your menu item. You can't remove it in Joomla with 2 exceptions:
- The menu item is the hompage of your website. In that case the menu item alias is removed automatically by the SEF system of Joomla. So, provided that your homepage is a menu item of the type HikaShop categories listing, you could select it in the "menu" setting of your module (where the URL is generated) and you would get the links without the menu item alias automatically.
- You're using a third party SEF extension like SH404SEF which allows you to have aliases for the URLs on your website.
The part "category" of the URL can be removed by emptying the field "category SEF name" in the HikaShop configuration page.

You could of course modify the router.php to remove these parts, but the Joomla SEF system won't be able to interpret the URLs without the menu item alias in them so it would require an extra system plugin to translate the URLs before the Joomla routing. So it's going to be quite complex and take quite some time to develop. In that case, it would be best to use a third party SEF extension with an alias system so that you could put the URLs you want in it.

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

  • Posts: 3
  • Thank you received: 0
9 years 6 months ago #231583

Thanks a lot for your prompt reply.

I solved for the first part of the URL by setting the menu as the homepage as you suggested.

For the second part of the URL the problem is that I can't remove "category" by emptying the field "category SEF name" in the HikaShop configuration page. I did it but It says that I can't leave blank product SEF name and category SEF name at the same time (and I need product SEF name empty).

How can I do to fix that by emptying both?

Thanks for your feedback

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

  • Posts: 84307
  • Thank you received: 13701
  • MODERATOR
9 years 6 months ago #231591

Similarily, removing both is not a problem when you create the URLs, but when HikaShop interprets the URLs, it won't know which one it is and thus it won't be able to choose between both type of pages.
To avoid that, what you can do is create one menu item for each category reproducing the category structure in the menu items structure. That way, you'll be able to have the aliases of the menu items for the categories on the listings (and thus you won't have the "category" piece anymore in the URLs).

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

  • Posts: 3
  • Thank you received: 0
9 years 6 months ago #231668

I already created the menu items for each category in fact the URL is

www.example.com/hikashop-menu-for-module...ory/my-category-name

where my-category-name is a menu item.

And, actually I didn't solve the problem at all since I cant' set the "hikashop-menu-for-module-123" as the homepage....

Let's try in another way. If I disassociate the menu in order to have a URL like this

www.example.com/component/hikashop/category/my-category-name

how can I remove ' component/hikashop/category' from the URL by modifying the router.php file?

thanks

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

  • Posts: 84307
  • Thank you received: 13701
  • MODERATOR
9 years 6 months ago #231677

Hi,

If you have your home menu item as a hikashop categories listing menu item and that you also have a child menu item of that menu item being also a hikashop categories listing menu item but with the corresponding sub category selected, then I don't see why you would get the "category" piece in the SEF URL. You must have missed something in the settings of the menu items, or you've set a canonical URL in the category with the "category" part in it and you've configured HikaShop to use the canonical URLs on listings.

Removing parts of the URL in the router.php is easy if you're a developer.
At the begining of the function HikashopBuildRoute( &$query ), just remove the bits you don't want in $query.
For example, for category:

if($query['ctrl']=='category') unset($query['ctrl']);
So just look at wat you have in $query with a var_dump() and add the code correspondingly.

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

Time to create page: 0.070 seconds
Powered by Kunena Forum