tinacious Posted October 16, 2012 Posted October 16, 2012 Hello. I find that when I make new ProcessWire sites I am often re-creating similar fields and templates. Is it possible to export/import/reuse this "setup" easily? I don't want the content just the fields and templates. Is this possible? I guess I'm looking for a solution similar to Drupal's Features export. Thanks for your help.
apeisa Posted October 16, 2012 Posted October 16, 2012 No, not yet. This feature has been discussed before and it is coming at some point. Probably as a JSON export/import. More reading: http://processwire.com/talk/topic/1284-best-practice-for-staging-to-live-database-synchronization/#entry12752 1
ryan Posted October 16, 2012 Posted October 16, 2012 If I understand the question correctly, you indicated "new ProcessWire sites" in which case you should check out the Site Profile Exporter to create your own starting profile to use instead of the included Basic Profile. 2
tinacious Posted November 11, 2012 Author Posted November 11, 2012 Thank you both, this is very helpful. I appreciate your help and LOVE ProcessWire! 2
Pete Posted June 30, 2013 Posted June 30, 2013 I'm in the process of building a complicated module and was thinking that being able to create the fields in the admin quickly, then export as a JSON string to use in the installer function would be much quicker than what I'm faced with at the moment - manually typing out the code for all the fields I need to add is taking a long time, so aside from the uses when copying fields/templates to other PW installations it would be fantastic to be able to generate the JSON and in a module's installer just do something like this if we wanted to change some template details or add some additional fields: $templatedata = json_decode($jsonstring); $fieldgroup = new Fieldgroup($templatedata->fields); $template = new Template(); $template->name = "template-name"; $template->fieldgroup = $fieldgroup; $template->save(); Or if we were happy with the template name we'd exported and all the fields, then this: // Adding template "template name" $templatedata = json_decode($jsonstring); $template = new Template($templatedata); // $templatedata contains template and field information $template->save(); The second option means you won't even know what the template is called unless you know how to read a JSON string, but I like its simplicity, and we can just put a comment above it as in my example Just a thought. 3
ryan Posted July 3, 2013 Posted July 3, 2013 I agree, I think export/import methods like this on Fields and templates would be nice. There's a lot of considerations though, especially on import. Like whether individual fields already exist or not, whether those field definitions reference external things (like page IDs). That's not to say it isn't doable, but just that there is potential for it to get quite a bit more complex than it first appears. But I would like to implement some API level expor/import functions for this soon, to at least get things moving forward. I've already been working on similar export/import functions for Page objects (which you see in the latest dev branch, though they aren't yet active). 7
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