Cms page locale

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Stefanki
Posts: 7
Joined: 02 Feb 2022, 16:12

Cms page locale

Post by Stefanki » 27 Sep 2023, 02:13

Php: 8.2.10
Laravel: 10.24.0
Aimeos-laravel: 2023.07.1
Hello,
It is about the demo-homepage route that we can see in the CMS in the panel admin is /, so when i changed SHOP_MULTILOCALE to "true", the root path of the website is redirected to "/{locale}", but the content of the demo-homepage is not rendered, it also seems that "/{locale}/p/{path?}" route work only if "path" is not null.

How to configure the aimeos routes "/{locale}" to render demo-homepage ?

Thank you in advance for your attention

User avatar
aimeos
Administrator
Posts: 7895
Joined: 01 Jan 1970, 00:00

Re: Cms page locale

Post by aimeos » 27 Sep 2023, 06:53

Change the URL of the page in the CMS panel from "/" e.g. to "/en/"
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Stefanki
Posts: 7
Joined: 02 Feb 2022, 16:12

Re: Cms page locale

Post by Stefanki » 27 Sep 2023, 08:42

Thank you for the answer,
but if i do that, it only work when locale = en, it still not work when locale = de for exemple.

User avatar
aimeos
Administrator
Posts: 7895
Joined: 01 Jan 1970, 00:00

Re: Cms page locale

Post by aimeos » 29 Sep 2023, 06:58

CMS page module use two variables to determine the page to be shown:
- the {path} URL segment if available
- the full path if the {path} URL segment isn't available

See: https://github.com/aimeos/ai-cms-grapes ... d.php#L306

If you want to use the {path} URL segment, check your routes if they match with your URLs using:

Code: Select all

php artian route:list
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Stefanki
Posts: 7
Joined: 02 Feb 2022, 16:12

Re: Cms page locale

Post by Stefanki » 30 Sep 2023, 02:24

From your answer, i think it was just the right starting point to fix the problem i had!

I added this to my routes, so only the route "/" has {locale?} (because changing aimeos_home prefix in shop.php changed a lot of others routes)

if( ( $conf = config( 'shop.routes.home', ['middleware' => ['web']] ) ) !== false ) {
Route::match( array( 'GET', 'POST' ), '/', array(
'as' => 'aimeos_home',
'uses' => 'Aimeos\Shop\Controller\CatalogController@homeAction'
) )->where( ['locale?' => '[a-z]{2}(\_[A-Z]{2})?', 'site' => '[A-Za-z0-9\.\-]+'] );


Route::group( $conf, function() {
Route::match( array( 'GET', 'POST' ), '/', array(
'as' => 'aimeos_home',
'uses' => 'Aimeos\Shop\Controller\CatalogController@homeAction'
) )->where( ['locale' => '[a-z]{2}(\_[A-Z]{2})?', 'site' => '[A-Za-z0-9\.\-]+'] );

});
}
Transferred SetLocale middleware in web middleware,

...
app()->setLocale($locale);
$request->merge([ 'locale' => $locale]);

It seems to work like a charm :)

Thank you again!

User avatar
aimeos
Administrator
Posts: 7895
Joined: 01 Jan 1970, 00:00

Re: Cms page locale

Post by aimeos » 30 Sep 2023, 08:11

The correct setup for the home page in multi-site setups is described here:
https://aimeos.org/docs/latest/laravel/ ... /#homepage
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Stefanki
Posts: 7
Joined: 02 Feb 2022, 16:12

Re: Cms page locale

Post by Stefanki » 30 Sep 2023, 11:11

Shall i edit the topic and write [SOLVED] ? Sorry i have almost never asked for help on a forum before.

User avatar
aimeos
Administrator
Posts: 7895
Joined: 01 Jan 1970, 00:00

Re: Cms page locale

Post by aimeos » 30 Sep 2023, 17:27

No, it's OK :-)
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply