{"action":"created","issue":{"url":"https://api.github.com/repos/backdrop/backdrop-issues/issues/1238","labels_url":"https://api.github.com/repos/backdrop/backdrop-issues/issues/1238/labels{/name}","comments_url":"https://api.github.com/repos/backdrop/backdrop-issues/issues/1238/comments","events_url":"https://api.github.com/repos/backdrop/backdrop-issues/issues/1238/events","html_url":"https://github.com/backdrop/backdrop-issues/issues/1238","id":107441838,"number":1238,"title":"Feature/Package Module Proposal","user":{"login":"behindthepage","id":434773,"avatar_url":"https://avatars.githubusercontent.com/u/434773?v=3","gravatar_id":"","url":"https://api.github.com/users/behindthepage","html_url":"https://github.com/behindthepage","followers_url":"https://api.github.com/users/behindthepage/followers","following_url":"https://api.github.com/users/behindthepage/following{/other_user}","gists_url":"https://api.github.com/users/behindthepage/gists{/gist_id}","starred_url":"https://api.github.com/users/behindthepage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/behindthepage/subscriptions","organizations_url":"https://api.github.com/users/behindthepage/orgs","repos_url":"https://api.github.com/users/behindthepage/repos","events_url":"https://api.github.com/users/behindthepage/events{/privacy}","received_events_url":"https://api.github.com/users/behindthepage/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-09-21T04:24:18Z","updated_at":"2015-09-21T07:29:22Z","closed_at":null,"body":"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.\r\n\r\nThis 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\r\nBut 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.\r\n\r\nI 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.\r\n\r\nTo 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.\r\n\r\nSo to modify my blog example \r\nThe views and layout files would be in blog/addons\r\n\r\nblog/addons/layout.layout.news.json\t\r\nblog/addons/views.view.archives.json\r\nblog/addons/views.view.news.json\r\nblog/addons/views.view.tags.json\r\n\r\nand the function in the install file would be\r\n\r\n```php\r\nfunction blog_register_addons() {\r\n\r\n  $addons['blog'] = array(\r\n    'description' => 'Provides a blog and archive pages.',\r\n    'config_files' => array(\r\n       'views.view.blog_news' => array(\r\n        'description' => 'Provides a blog view.',  \r\n      ),\r\n      'views.view.blog_archives' => array(\r\n        'description' => 'Provides an archive page and archive navigation block.',\r\n      ),\r\n      'views.view.blog_tags' => array(\r\n        'description' => 'Provides a tags block.',\r\n      ),\r\n      'layout.layout.blog_news' => array(\r\n        'description' => 'Provides a loyout for the blog page at /news.',\r\n      ),\r\n    ),\r\n  );\r\n\r\n  return $addons;\r\n}\t\r\n```\r\nWhen 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.\r\n\r\nWhen 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.\r\n\r\nI have used the name \"addons\" but it could be \r\nblog_register_feature() \r\nblog_register_package() \r\nor something else.\r\n\r\nRelated discussions:\r\nhttps://github.com/backdrop/backdrop-issues/issues/1045\r\nhttps://github.com/backdrop/backdrop-issues/issues/881\r\n\r\nWhat does everyone think?\r\n\r\nRegards\r\nGeoff\r\n"},"comment":{"url":"https://api.github.com/repos/backdrop/backdrop-issues/issues/comments/141897776","html_url":"https://github.com/backdrop/backdrop-issues/issues/1238#issuecomment-141897776","issue_url":"https://api.github.com/repos/backdrop/backdrop-issues/issues/1238","id":141897776,"user":{"login":"quicksketch","id":100206,"avatar_url":"https://avatars.githubusercontent.com/u/100206?v=3","gravatar_id":"","url":"https://api.github.com/users/quicksketch","html_url":"https://github.com/quicksketch","followers_url":"https://api.github.com/users/quicksketch/followers","following_url":"https://api.github.com/users/quicksketch/following{/other_user}","gists_url":"https://api.github.com/users/quicksketch/gists{/gist_id}","starred_url":"https://api.github.com/users/quicksketch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quicksketch/subscriptions","organizations_url":"https://api.github.com/users/quicksketch/orgs","repos_url":"https://api.github.com/users/quicksketch/repos","events_url":"https://api.github.com/users/quicksketch/events{/privacy}","received_events_url":"https://api.github.com/users/quicksketch/received_events","type":"User","site_admin":false},"created_at":"2015-09-21T07:29:22Z","updated_at":"2015-09-21T07:29:22Z","body":"> 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.\r\n\r\nI think this would be a good idea in any case. We shouldn't allow modules to be enabled at all if they have conflicting config file names with any existing config.\r\n\r\n> 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.\r\n\r\nAll config files owned by a module are already uninstalled, but I see how this is different in that config files that aren't necessarily owned by a module would also be removed. For example \"my_module.module\" might provide \"my_module.settings.json\", which would be automatically installed. But \"views.view.my_module_view.json\" would not. because it's namespace-wise owned by Views, not my_module.\r\n\r\nThe thing I'm a little puzzled by in this proposal is that you already know what default config files a module ships with, don't you? They're the files that are in the module's `config` directory. Although the hook could provide some human-readable names, it seems like you'd already have the information needed to uninstall related config files."}}