Jump to content

How to copy fields and templates across PW installations?


Robert Zelník
 Share

Recommended Posts

When I create a new web site, I use two installations: a local (devel) site, where I test new changes, and a remote site, where I apply these changes when they work well. I would like to avoid duplicate work with creating fields and templates twice. Is there any intelligent way to clone these fields and templates between the local site and the remote site?

Link to comment
Share on other sites

No, not yet. Ryan has mentioned a method to export & import templates with fields using JSON. That would be great in many ways. Currently it is easy to export full site profiles, but that doesn't help in your scenario. Or other scenario where you want transfer certain templates from one site to an another (ie. you have build great product catalog on site X and want it to site Y also).

One way is to build module that creates all the required fields and templates, but I find it pretty cumbersome for that task.

Ryan: have you had time to look into this? I am available to help here, since this is very important stuff for our company. If you can share your initial thoughts on this, and I could try taking this further from there.

  • Like 1
Link to comment
Share on other sites

  • 4 years later...

The JSON import/export functionality Ryan is talking about is already in the admin. The buttons are located on the bottom side of the Fields and Templates page in the admin:

Screen Shot 2016-11-07 at 10.58.43.png

Screen Shot 2016-11-07 at 10.58.51.png

If you want to automate database migrations you could use the Migrations module by lostkobrakai. There are several other posts floating around dealing with this issue.

  • Like 4
Link to comment
Share on other sites

I have tried to use the JSON Import/exporter but I got some strange results?

I was testing a new survey functionality, so I recreated a live version of our site on our test site by running a DB Export of the live site and deploying the live code.

Then I applied the new survey code and applied JSON Imported that contained definitions of new templates / field for the Survey functionality.

When I ran this particular query, it was returning "phantom" pages that were in the test system prior to the system refresh as well as the new test data I had entered post deployment.

 

$home = wire(pages)->get("/Survey, include=all");

 

The results were a bit baffling. I did check to see if the JSON definitions contained any "data" but I couldn't see any. I could only speculate that the DB Export script somehow doesn't delete any new DB objects in the target system prior to a rebuild/refresh.

I am using MySQLWorkBench and just using Export function with default settings. I've been using this for a year now and never had any problems with site refresh/ rebuilds.

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