robertgarrigos's picture

I'm working on an install profile and want to have some custom settings for the default layout as well as the default administrative layout. I tried to have my own json file for them, but layout module overrides them. Can I override the default layouts or alter them during the installation of the profile?

Accepted answer

I think the default layout has to be the one called "default". 

I think you'd need in your profile.install to config_set() the defaults you want. 

Most helpful answers

Thanks all. I tried @docwilmot solution and worked perfectly:

 

// Set default layouts.
  config_set('layout.layout.default', 'layout_template', $new_value);
  config_set('layout.layout.admin_default', 'layout_template', $new_value);

Comments

I think the issue with setting your layout on install comes from the path set by the default layout. 

https://github.com/backdrop/backdrop/blob/1.x/core/modules/layout/layout...

The layout configs are gathered when matching layouts to paths, and for me, I see the path of the default layout being "", which matches all paths. 

I think if you load the default layout during install and set it's path to "/something-that-can-never-be-reached" and set your layout at "", then your layouts would take over. I'm not sure "" passes the 

isset($config['path'])

part, in 

https://github.com/backdrop/backdrop/blob/1.x/core/modules/layout/layout...

though.

You might be able to import your json in an update hook in your install profile.

I think the default layout has to be the one called "default". 

I think you'd need in your profile.install to config_set() the defaults you want. 

robertgarrigos's picture

Thanks all. I tried @docwilmot solution and worked perfectly:

 

// Set default layouts.
  config_set('layout.layout.default', 'layout_template', $new_value);
  config_set('layout.layout.admin_default', 'layout_template', $new_value);