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
Welcome to Backdrop! For your setup, you’ll want to create a subtheme of Bootstrap5 Lite itself; the Bootswatch styles (like Cerulean) are just presets that B5 Lite loads, and you can “lock in”...
Basic Theme designing questions, using Bootstrap5 Lite
Hi Rob, Welcome to Backdrop! Here’s a quick overview: Subtheming Bootswatch: You should create your subtheme based on Bootstrap5 Lite, not directly on a Bootswatch style....
Basic Theme designing questions, using Bootstrap5 Lite
Hi Rolf, This happens because CKEditor saves absolute or semi-absolute paths in the HTML instead of using Backdrop’s file stream wrappers (like public://). When you move your site...
Losing link to embedded pictures when moving my installation