Using same route for different controllers?
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Using same route for different controllers?
Laravel framework version: 10.13.5
Aimeos Laravel version: ~2023.04
PHP Version: 8.2.7
Environment: Linux
Hello,
I want my CMS pages route and Products route to be the same.
It needs to accept any URL, check if the CMS page route exists, if it doesn't exist, redirect to the Products route.
That's why I have my routes in this order:
I'm planning to override this file and make changes for the body() method.
Aimeos\Client\Html\Cms\Page::body()
Inside this check on row 179:
Problem is that I don't know how I can redirect to the product listing controller and pass the initial path that was passed to the CMS page to it.
How can I achieve this?
Aimeos Laravel version: ~2023.04
PHP Version: 8.2.7
Environment: Linux
Hello,
I want my CMS pages route and Products route to be the same.
It needs to accept any URL, check if the CMS page route exists, if it doesn't exist, redirect to the Products route.
That's why I have my routes in this order:
Code: Select all
// CMS Page
Route::match( ['GET', 'POST'], '{path?}', [
'as' => 'my_page',
'uses' => '\Aimeos\Shop\Controller\PageController@indexAction',
])->where([
'path' => '.*'
]);
// Product listing
Route::match( ['GET', 'POST'], '{f_name?}', array(
'as' => 'my_shop_tree',
'uses' => 'Aimeos\Shop\Controller\CatalogController@treeAction'
))->where([
'locale' => '[a-z]{2}(\_[A-Z]{2})?',
'site' => '[A-Za-z0-9\.\-]+',
'f_name' => '.*'
]);
Aimeos\Client\Html\Cms\Page::body()
Inside this check on row 179:
Code: Select all
if( !isset( $view->pageCmsItem ) ) {
// Redirect to to product listing (my_shop_tree) Aimeos\Shop\Controller\CatalogController@treeAction
}
How can I achieve this?
Last edited by kdim95 on 30 Jun 2023, 14:05, edited 1 time in total.
Re: Using same route for different controllers?
The same route can't be matched by different controllers, the first one will always win.
If you add the catalog list and cms page components to the same page, the catalog controller will handle the route and the cms page component will match to the URL path (not the route). Then, add a cms page with the same URL path in the CMS panel of the admin backend.
If you add the catalog list and cms page components to the same page, the catalog controller will handle the route and the cms page component will match to the URL path (not the route). Then, add a cms page with the same URL path in the CMS panel of the admin backend.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star