kongondo Posted September 1, 2014 Posted September 1, 2014 Is there a way to abort the installation of a module using the API if a certain condition is not met? I am trying to incorporate the module SchedulePages in my module Blog. Instructions would be for the user to first install SchedulePages. But users being users.... ....In case they attempt to first install Blog, I would like to halt the process if SchedulePages is not found. The reason is Blog will need to grab the two date fields created by SchedulePages and add them to the template 'blog-post'. I tried adding some logic in ___install() and init() but got no joy. Blog module was installed anyway. Should I be hooking into something? What is the process flow when modules are installed? What is called first? This situation I describe also arises because currently, AFAIK, PW will not download and install a third party module from the modules directory just because another module requires it. In my case, just because Blog says it requires 'SchedulePages does not mean PW will install it automatically if it is not bundled with Blog . Such third party modules need to be bundled with the module trying to install them. I suppose that is still the case. I tried Thanks.
adrian Posted September 1, 2014 Posted September 1, 2014 These might come in handy: $this->modules->isInstalled() $this->modules->getInstall() I used these in Migrator for detecting if third party modules are installed and if they are available to install. 2
kongondo Posted September 1, 2014 Author Posted September 1, 2014 (edited) Thanks guys @Adrian, But getInstall() will only install modules available to install on your server no? I mean, it will not go to the ProcessWire modules directory to download (like ModulesManager) and install the 'missing' module, would it? I have tried and I get the message 'SchedulePages' installed but it isn't. I guess I could just write a script to go and download the module if it is not on the server, then install it. I am trying to avoid bundling the third party module with Blog if I can, thanks. Not to worry guys. Changed my mind..., too much effort......I'll just abort if people don't follow instructions Edited September 1, 2014 by kongondo 1
adrian Posted September 1, 2014 Posted September 1, 2014 But getInstall() will only install modules available to install on your server no? I mean, it will not go to the ProcessWire modules directory to download Yeah, it won't go and download it, but it will tell you if it is available to install. I mostly just used $this->modules->get to check, but that didn't seem to work for inputfields (eg InputfieldSelectMultipleTransfer) and inputfield classes (eg CKEditor - when it was a separate module).
kongondo Posted September 1, 2014 Author Posted September 1, 2014 Ta. In fact thought about this further. I will make this optional. If the user wants to use SchedulePages Blog will use it if it is installed if not, they won't get the experience. I'll write more in the Blog forum...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now