- Posts: 8
- Thank you received: 1
Create category link with content Menu alias only
13 years 4 months ago - 13 years 4 months ago #109979
by pipedream
Create category link with content Menu alias only was created by pipedream
I am adding a link to the product category in the view product / show.php .
This link is a Menu item of the type Products listing, so it is also present in Hikashop Content menus:
So, in the view I was expecting this code to work:
But this returns:
/example/product/listing
Should it return the "/product/listing", since it is unecessary?
Is there a better way of getting only "/example" than doing something like this?
Thanks!
This link is a Menu item of the type Products listing, so it is also present in Hikashop Content menus:
| Alias | Type | Link |
| example | product | index.php?option=com_hikashop&view=product&layout=listing |
So, in the view I was expecting this code to work:
Code:
JRoute::_('index.php?option=com_hikashop&view=product&layout=listing'.$url_itemid.$lang);
But this returns:
/example/product/listing
Should it return the "/product/listing", since it is unecessary?
Is there a better way of getting only "/example" than doing something like this?
Code:
preg_replace('/\/product\/listing$/', '', JRoute::_('index.php?option=com_hikashop&view=product&layout=listing'.$url_itemid.$lang));
Thanks!
Last edit: 13 years 4 months ago by pipedream. Reason: formatting
Please Log in or Create an account to join the conversation.
13 years 4 months ago #110051
by nicolas
Replied by nicolas on topic Create category link with content Menu alias only
Hi,
That should indeed be the case if the option "Activate smaller url" of the configuration is turned on.
That should indeed be the case if the option "Activate smaller url" of the configuration is turned on.
Please Log in or Create an account to join the conversation.
13 years 4 months ago - 13 years 4 months ago #110118
by pipedream
Replied by pipedream on topic Create category link with content Menu alias only
It is.
SEF url options
SEF url options
Code:
Simplified breadcrumbs: Yes
Activate smaller url..: Yes
Category SEF name.....: categoria
Product SEF name......: (I left this empty)
Last edit: 13 years 4 months ago by pipedream. Reason: formatting
Please Log in or Create an account to join the conversation.
13 years 4 months ago #110134
by nicolas
Replied by nicolas on topic Create category link with content Menu alias only
Maybe you can try with ctrl instead of view and task instead of layout as that's what we're normally using inside hikashop but normally it should also work with view and layout.
Please Log in or Create an account to join the conversation.
13 years 4 months ago - 13 years 4 months ago #110161
by pipedream
gives the same result:
/example/product/listing
Took a quick look at /components/com_hikashop/router.php and it seems that the only menu types where the crtl/task or layout/view pairs are being unset are the category listing and product show.
So, the "/product/listing" part can only be avoided by adding:
which I won't add, at least until I further understand if I'm not ruining anything else.
Should HikaShop router better understand which menus correspond to its builded links, thus avoiding unecessary added segments?
Replied by pipedream on topic Create category link with content Menu alias only
Code:
JRoute::_('index.php?option=com_hikashop&ctrl=product&task=listing'.$url_itemid.$lang);
/example/product/listing
Took a quick look at /components/com_hikashop/router.php and it seems that the only menu types where the crtl/task or layout/view pairs are being unset are the category listing and product show.
So, the "/product/listing" part can only be avoided by adding:
Code:
else if($query['view']=='product' && $query['layout']=='listing'){
unset( $query['layout'] );
unset( $query['view'] );
}
Should HikaShop router better understand which menus correspond to its builded links, thus avoiding unecessary added segments?
Last edit: 13 years 4 months ago by pipedream. Reason: formatting
Please Log in or Create an account to join the conversation.
13 years 4 months ago #110240
by nicolas
Replied by nicolas on topic Create category link with content Menu alias only
Ok I see what you mean.
But no, if you want to have only the menu alias you should give only the menu itemid.
So I think that what you want actually is to use the code:
Because joomla already knows that you want a products listing using the type of the menu of the itemid of the URL.
That's why the URLs of products listings don't have the product/listing part.
But no, if you want to have only the menu alias you should give only the menu itemid.
So I think that what you want actually is to use the code:
Code:
JRoute::_('index.php?option=com_hikashop'.$url_itemid.$lang);
Because joomla already knows that you want a products listing using the type of the menu of the itemid of the URL.
That's why the URLs of products listings don't have the product/listing part.
The following user(s) said Thank You: pipedream
Please Log in or Create an account to join the conversation.
13 years 4 months ago #110257
by pipedream
Replied by pipedream on topic Create category link with content Menu alias only
Perfect solution, merci!!!
For some mysterious reason I thought JRoute also needed the ctrl/task or view/layout pair...
For some mysterious reason I thought JRoute also needed the ctrl/task or view/layout pair...
Please Log in or Create an account to join the conversation.
Time to create page: 0.103 seconds