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
Hello, @yorkshirepudding! Thanks a lot, I got it, all sorted out.
My layout template (layout--blog.tpl.php) doesn't work
Hi @Gnome and welcome to Backdrop When I create custom layout templates I put them in /layouts/custom/my_layout Note: you can split modules and layouts between contrib and custom...
My layout template (layout--blog.tpl.php) doesn't work
This post explains how to do this in Drupal 7. In Backdrop, File Entity is already part of core. You will need to download and install module Views Field View. https://drupal.stackexchange...
I Need to Display an Image in a View that was Uploaded to a Webform