Backdrop needs a system to enable modules to easily and safely add views and layouts to a sites config folder. Then modules can add "Features" with a combination of views and layouts config files.
This can be done now by having the views and layouts in the modules /config folder which are automatically added to the sites config folder. An example of a WP blog "features" modules that will do this is here https://github.com/behindthepage/blog But the danger with this approach is that these files may over write files with the same name or create views and layouts with duplicate paths and the views and layouts are not removed when the module is disabled and uninstalled.
I envisage a system where a module can declare it's "addon" views and layouts and when enabled Backdrop checks that there are no naming or path issues and when disabled Backdrop disabled the views and layouts and deletes them when uninstalled maybe asking the user to confirm the deletion.
To make this work I suggest adding a hook_register_addons() function to the module's install file and having an extra folder in the module folder for the addon views and layouts.
So to modify my blog example The views and layout files would be in blog/addons
blog/addons/layout.layout.news.json blog/addons/views.view.archives.json blog/addons/views.view.news.json blog/addons/views.view.tags.json
and the function in the install file would be
function blog_register_addons() {
$addons['blog'] = array(
'description' => 'Provides a blog and archive pages.',
'config_files' => array(
'views.view.blog_news' => array(
'description' => 'Provides a blog view.',
),
'views.view.blog_archives' => array(
'description' => 'Provides an archive page and archive navigation block.',
),
'views.view.blog_tags' => array(
'description' => 'Provides a tags block.',
),
'layout.layout.blog_news' => array(
'description' => 'Provides a loyout for the blog page at /news.',
),
),
);
return $addons;
}
When the module is enables backdrop would check that there is no naming issues, warn of any path issues and copy these files into the sites config folder.
When the module is disabled or uninstalled a information pane would appear explaining what the views and layouts did and asking for confirmation that thay can be deleted. It could also explain to get them back you can just enable the module again.
I have used the name "addons" but it could be blog_register_feature() blog_register_package() or something else.
Related discussions: https://github.com/backdrop/backdrop-issues/issues/1045 https://github.com/backdrop/backdrop-issues/issues/881
What does everyone think?
Regards Geoff
Recent comments
well @herb I cannot believe it, but the webform module was there in modules on the disc, but missing in the listed modules, so I delete the module folder, and downloaded it again. Then...
My Webform Worksheets have disappeared
The only thing I can think of is to make sure Webform module is enabled and that the content type that needs to contain the webforms has Webform enabled for it. Edit the content type and make...
My Webform Worksheets have disappeared
@yorkshirepudding, In the end I fixed it by deleting the config/active folder contents, copying the config/staging/ files into config/active, importing the database again and clearing the caches...
Importing the staged config throws an error: another field with the same name already exists