Jump to content

Module to generate app fields, templates, and roles -- what to hook?


hellomoto
 Share

Recommended Posts

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

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.

  • Like 2
Link to comment
Share on other sites

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...