Jump to content

module installs new template and fields... example please!


gunter
 Share

Recommended Posts

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

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.

  • Like 2
Link to comment
Share on other sites

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

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

 

 

 

  • Like 2
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...