hellomoto Posted January 10, 2015 Share Posted January 10, 2015 Hi, I want to write up a module that upon installation generates my site fields, templates, and roles... What hook do I use? This is a better approach than simply exporting a Site Profile, no? Thanks... Link to comment Share on other sites More sharing options...
Mike Rockett Posted January 10, 2015 Share Posted January 10, 2015 Hi I think it would depend on the reason you're doing it... I keep a base site profile handy for my sites. It's also handy in terms of base assets that are common throughout these sites. Doing it in a module wouldn't be as easy... I'm not sure about the hooks - someone else may be able to help you there. Link to comment Share on other sites More sharing options...
teppo Posted January 10, 2015 Share Posted January 10, 2015 Site profiles are definitely the way to go if it's something you can decide right from the start; "to begin with, this site will have these fields, these templates, ..." etc. Module would be more beneficial if it's a feature you may want to add later on. A blog or discussion module installing its own fields and templates, and so on. For the actual answer, you don't use hooks for this. Include install() method in your module, and create anything you need there -- and uninstall(), if you want to be able to clean up anything created by this module just by uninstalling it. These run automatically when ProcessWire installs or uninstalls a module. For examples, this is how ProcessVersionControl does it, and here's how it's handled in ProcessUserGroups. 2 Link to comment Share on other sites More sharing options...
mr-fan Posted January 10, 2015 Share Posted January 10, 2015 ...and there is great migrator tool for up and running site to get some templates, fields and so on from one to another. https://processwire.com/talk/topic/8660-migrator/ have fun 1 Link to comment Share on other sites More sharing options...
hellomoto Posted January 15, 2015 Author Share Posted January 15, 2015 Hey thanks guys. I've realized the ease of simply exporting a site profile, which is serving me well. Someone else pointed Migrator out to me too, but with the profile export I haven't even gotten around to trying that yet... I do have it installed... 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