Page 1 of 1

Want To Change Category Url

Posted: 14 Jan 2020, 14:36
by awaidqureshi
Default category url is http://......com/catgegoryname~categoryid

want to change it to only category name means
http://......com/catgegoryname

Please guide how can i do that

Thanks

Re: Want To Change Category Url

Posted: 14 Jan 2020, 15:02
by aimeos
That will be difficult because the category name must be unique then and this is only rarely the case. Furthermore, things get more complicated if category names should translated into several languages.

For products, we've added a resolve() method to the product frontend controller that is used in the HTML client and which finds the product by its name:
https://github.com/aimeos/ai-controller ... #L294-L310

Re: Want To Change Category Url

Posted: 20 Jan 2020, 10:18
by awaidqureshi
aimeos wrote: 14 Jan 2020, 15:02 That will be difficult because the category name must be unique then and this is only rarely the case. Furthermore, things get more complicated if category names should translated into several languages.

For products, we've added a resolve() method to the product frontend controller that is used in the HTML client and which finds the product by its name:
https://github.com/aimeos/ai-controller ... #L294-L310
Can i replace this "~" with forward slash if yes then where i have to do the changes

Re: Want To Change Category Url

Posted: 21 Jan 2020, 09:49
by aimeos
Only if you change the product detail routes too because they already use a "/" for separating name and id and/or pos. Otherwise, the Laravel router won't be able to distingish which route to use.

You can add a prefix like /category_name/c/123 to make routes unique.

Re: Want To Change Category Url

Posted: 09 Apr 2021, 13:19
by ttyy
Is is possible to create a custom route for instance /mytestpage/{f_catid} for category view? If so how I would disable required f_name param?

I've tried a similar approach, created a router but w/o f_name i'm getting an error handling the request

Error --
Illuminate\Routing\Exceptions\UrlGenerationException
Missing required parameter for [Route: aimeos_shop_tree] [URI: shop/{f_name}~{f_catid}] [Missing parameter: f_name].
URL: http://localhost:8000/category/2
Route: Route::get('category/{f_catid}/{f_name?}', '\Aimeos\Shop\Controller\CatalogController@treeAction');
Also same results with route: 'category/{f_catid}'

Re: Want To Change Category Url

Posted: 11 Apr 2021, 12:08
by aimeos
You can overwrite existing Laravel routes by their name in ./routes/web.php, e.g.:

Code: Select all

Route::match( array( 'GET', 'POST' ), 'mytestpage/{f_catid}', array(
	'as' => 'aimeos_shop_tree',
	'uses' => 'Aimeos\Shop\Controller\CatalogController@treeAction'
) )->where( ['site' => '[a-z0-9\.\-]+' );
Because the f_name parameter is added when the URL is generated in the template, it will be part of the URL as

Code: Select all

/mytestpage/123?f_name=test

Re: Want To Change Category Url

Posted: 14 Apr 2021, 11:47
by ttyy
Thanks, adding name for the route did the trick!