gunter Posted December 15, 2019 Share Posted December 15, 2019 Do you know a module that installs some new templates and fields - so I can take it as example? It should loop trough the templates/fields it has to install and checking their existence before it installs them and it would be nice, if they are deinstalled too, if they are not used. I had once an example, but I forget where ? Link to comment Share on other sites More sharing options...
gebeer Posted December 15, 2019 Share Posted December 15, 2019 You can have a look at my relatively new help videos module. Relevant code starts here. All the basics for creating fields and templates and pages are there. Should be easy to build upon. The uninstalling part goes in the ___uninstall() method. You basically need to keep track about what you installed (e.g. save this info to your module config data) and then remove that stuff. 2 Link to comment Share on other sites More sharing options...
gunter Posted December 15, 2019 Author Share Posted December 15, 2019 2 hours ago, gebeer said: You can have a look at my relatively new help videos module. Relevant code starts here. Thanks, that´s nice what your example does, because I was looking for an example that uses pages like your module does... in the admin, too! ? Link to comment Share on other sites More sharing options...
Gadgetto Posted December 18, 2019 Share Posted December 18, 2019 You can have a look at my SnipWire module (currently in development). It has an extended installer class which creates fields, templates, pages, permissions, copies files to directories, ... using an array. Here is the installer:https://github.com/gadgetto/SnipWire/blob/dev/installer/ExtendedInstaller.php And here the resources array:https://github.com/gadgetto/SnipWire/blob/dev/installer/ExtendedInstaller.resources.php Link to comment Share on other sites More sharing options...
gunter Posted December 18, 2019 Author Share Posted December 18, 2019 Gadgetto thanks for your solution! ? Guys, I found what I was looking for: https://processwire.com/talk/topic/9007-utility-to-help-generate-module-install-function/ it just uses normal processwire json export strings for fields and templates and seems for me to be the simpliest solution... I used it once somewhere in a module, it worked, but I forget where I had it.. ? 2 Link to comment Share on other sites More sharing options...
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