Jump to content

Recommended Posts

Posted

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...

Posted

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.

Posted

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
Posted

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...

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
×
×
  • Create New...