how can we keep the sef url
- nico.van.leeuwen
-
Topic Author
- Offline
Less
More
2 years 9 months ago - 2 years 8 months ago #358168
by nico.van.leeuwen
how can we keep the sef url was created by nico.van.leeuwen
-- HikaShop version -- : 5.0.2
-- Joomla version -- : 5.0.2
-- PHP version -- : 8.2
Hi,
We made some layout overrides with it's own xml file that is used to change the way the prices are displayed.
We assign these via the menu-item, just like the category-listing.
Now for testing 2 menu-items have been created with only 1 setting different and that is that on item shop2 we set the custom category-listing with the option to modify the price display.
The thing that we have not yet figured out is that the url's are different then we expected:
domain.nl/shop1/product/4-brow-shoes (the default one)
domain.nl/hikashop-menu-for-brands-listing/product/4-brow-shoes (with our customisation)
When we turn of sef and rewrite they look like this :
domain.nl/index.php?option=com_hikashop&view=category&layout=listing&Itemid=136
domain.nl/index.php?option=com_hikashop&view=category&layout=cassiopeia:listing-custom&Itemid=137
What did we mis that makes the url's different?
Any help or tips is much appreciated.
Nico
-- Joomla version -- : 5.0.2
-- PHP version -- : 8.2
Hi,
We made some layout overrides with it's own xml file that is used to change the way the prices are displayed.
We assign these via the menu-item, just like the category-listing.
Now for testing 2 menu-items have been created with only 1 setting different and that is that on item shop2 we set the custom category-listing with the option to modify the price display.
The thing that we have not yet figured out is that the url's are different then we expected:
domain.nl/shop1/product/4-brow-shoes (the default one)
domain.nl/hikashop-menu-for-brands-listing/product/4-brow-shoes (with our customisation)
When we turn of sef and rewrite they look like this :
domain.nl/index.php?option=com_hikashop&view=category&layout=listing&Itemid=136
domain.nl/index.php?option=com_hikashop&view=category&layout=cassiopeia:listing-custom&Itemid=137
What did we mis that makes the url's different?
Any help or tips is much appreciated.
Nico
Last edit: 2 years 8 months ago by nico.van.leeuwen. Reason: solved
Please Log in or Create an account to join the conversation.
2 years 8 months ago #358172
by nicolas
Replied by nicolas on topic how can we keep the sef url
Hi,
Mmm.
I could answer your question by telling you that it's normal that the two SEF URLs are different since the non SEF URLs, on which Joomla's SEF system bases itself to generate the SEF URLs, are different, but I suppose you already know that.
I could also answer your question by telling you that it's normal that the two URLs are different since the menu items used to access them are different, but I suppose you already know that too.
I could also tell you that it's possible to use only one of the two URLs by entering it in the "canonical URL" setting of the product and activating the "force canonical URLs on listing" setting of the HikaShop configuration, but knowing you're a long time user of HikaShop, I suppose you also already know that, and that's not even an exact answer to the question at the end of your message.
Basically, I'm not sure what you want to know, so I'm not sure what I should tell you.
Mmm.
I could answer your question by telling you that it's normal that the two SEF URLs are different since the non SEF URLs, on which Joomla's SEF system bases itself to generate the SEF URLs, are different, but I suppose you already know that.
I could also answer your question by telling you that it's normal that the two URLs are different since the menu items used to access them are different, but I suppose you already know that too.
I could also tell you that it's possible to use only one of the two URLs by entering it in the "canonical URL" setting of the product and activating the "force canonical URLs on listing" setting of the HikaShop configuration, but knowing you're a long time user of HikaShop, I suppose you also already know that, and that's not even an exact answer to the question at the end of your message.
Basically, I'm not sure what you want to know, so I'm not sure what I should tell you.
Please Log in or Create an account to join the conversation.
- nico.van.leeuwen
-
Topic Author
- Offline
2 years 8 months ago #358180
by nico.van.leeuwen
Replied by nico.van.leeuwen on topic how can we keep the sef url
Hi Nicolas,
Yes, you can tell me all these thing
But it's probably me having to explain better so here I go :
When using only 1 menu-item, excluding the canonical part I still get these two different url's :
domain.nl/shop2/product/4-brow-shoes
domain.nl/hikashop-menu-for-brands-listing/product/4-brow-shoes
Only by changing the menu-item-type to the one we created. The thing I cannot understand is where the "hikashop-menu-for-brands-listing" is coming from.
I'm sure that there can be something I'm overlooking, in that case I will need to buy you guys a beer
(or two)
Yes, you can tell me all these thing
But it's probably me having to explain better so here I go :
When using only 1 menu-item, excluding the canonical part I still get these two different url's :
domain.nl/shop2/product/4-brow-shoes
domain.nl/hikashop-menu-for-brands-listing/product/4-brow-shoes
Only by changing the menu-item-type to the one we created. The thing I cannot understand is where the "hikashop-menu-for-brands-listing" is coming from.
I'm sure that there can be something I'm overlooking, in that case I will need to buy you guys a beer
Please Log in or Create an account to join the conversation.
2 years 8 months ago #358181
by nicolas
Replied by nicolas on topic how can we keep the sef url
Hi,
If you have a products listing displayed by a menu item (and not by a module on that menu item), then the SEF URL of all the products on that listing will use the current menu item alias.
If that's not the case, then it probably means that you have the "canonical URL" setting of the product filled with the URL you see on the frontend and that you have the "force canonical URLs on listings" setting activated.
And if that's not the case, then the only thing I can think about is that you have a SEF extension like 4SEF which allows you to configure any SEF URL you want regardless of the aliases and the menu item.
If you have a products listing displayed by a menu item (and not by a module on that menu item), then the SEF URL of all the products on that listing will use the current menu item alias.
If that's not the case, then it probably means that you have the "canonical URL" setting of the product filled with the URL you see on the frontend and that you have the "force canonical URLs on listings" setting activated.
And if that's not the case, then the only thing I can think about is that you have a SEF extension like 4SEF which allows you to configure any SEF URL you want regardless of the aliases and the menu item.
Please Log in or Create an account to join the conversation.
- nico.van.leeuwen
-
Topic Author
- Offline
2 years 8 months ago #358197
by nico.van.leeuwen
Replied by nico.van.leeuwen on topic how can we keep the sef url
Hi Nicolas,
You mentioned all the thing I had checked many times to find a clue. But it does not seem the case here.
To make the test as clean as I can I now have 1 menu-item named "shop1" that is a categorie listing.
I tried it with the default HikaShop option and with the layout overrides we made with the same different url's :
domain.nl/shop1/product/4-brow-shoes
domain.nl/hikashop-menu-for-brands-listing/product/4-brow-shoes
The setting "Force canonical urls is set to "generete" and the menu-alias for both tests is "shop1".
I'm am left very puzzled
You mentioned all the thing I had checked many times to find a clue. But it does not seem the case here.
To make the test as clean as I can I now have 1 menu-item named "shop1" that is a categorie listing.
I tried it with the default HikaShop option and with the layout overrides we made with the same different url's :
domain.nl/shop1/product/4-brow-shoes
domain.nl/hikashop-menu-for-brands-listing/product/4-brow-shoes
The setting "Force canonical urls is set to "generete" and the menu-alias for both tests is "shop1".
I'm am left very puzzled
Please Log in or Create an account to join the conversation.
2 years 8 months ago #358198
by nicolas
Replied by nicolas on topic how can we keep the sef url
Hi,
Rereading everything here, I think I understand what's going on.
There is a check when HikaShop requests the SEF URL. This check makes sure that the Itemid used in the URL corresponds to the view and layout parameters of the non SEF URL. And to do this, the system look at the menu item ids with the format index.php?option=com_hikashop&view=category&layout=listing in the database.
But in your case, since you made a custom layout, this won't match. And in that case, the system will automatically use another menu item which matches. This is done in order to avoid 404 errors when menu items are not configured properly by the admin.
For example, if I configure a module to use the menu item with the id 100, but later on I delete that menu item, the module will still try to generate links for the menu item with the id 100. That would result in 404 errors. So HikaShop automatically correct the Itemid in the URL to use another one.
This backfires in your case because the link in the database doesn't correspond to what HikaShop expects.
Try adding the code:
after the code:
in the file administrator/components/com_hikashop/classes/menus.php
This way, the system will ignore the layout parameter when doing this check. This will still effectively prevent 404 errors with menu items not configured properly, while still allow for custom layouts.
Rereading everything here, I think I understand what's going on.
There is a check when HikaShop requests the SEF URL. This check makes sure that the Itemid used in the URL corresponds to the view and layout parameters of the non SEF URL. And to do this, the system look at the menu item ids with the format index.php?option=com_hikashop&view=category&layout=listing in the database.
But in your case, since you made a custom layout, this won't match. And in that case, the system will automatically use another menu item which matches. This is done in order to avoid 404 errors when menu items are not configured properly by the admin.
For example, if I configure a module to use the menu item with the id 100, but later on I delete that menu item, the module will still try to generate links for the menu item with the id 100. That would result in 404 errors. So HikaShop automatically correct the Itemid in the URL to use another one.
This backfires in your case because the link in the database doesn't correspond to what HikaShop expects.
Try adding the code:
Code:
}elseif(!empty($id)){
$filters[] = 'a.link LIKE \'index.php?option=com_hikashop&view='.($view=='manufacturer'?'category':$view).'&layout=%\'';
Code:
$filters[] = 'a.link LIKE \'index.php?option=com_hikashop&view=%\'';
This way, the system will ignore the layout parameter when doing this check. This will still effectively prevent 404 errors with menu items not configured properly, while still allow for custom layouts.
Please Log in or Create an account to join the conversation.
- nico.van.leeuwen
-
Topic Author
- Offline
2 years 8 months ago #358207
by nico.van.leeuwen
Replied by nico.van.leeuwen on topic how can we keep the sef url
That works perfect !
Thank you very much for this tip, don't know if would ever have found this
Thank you very much for this tip, don't know if would ever have found this
The following user(s) said Thank You: nicolas
Please Log in or Create an account to join the conversation.
Time to create page: 0.203 seconds