Jump to content

Questions: Export and Import pages or fields using the API


bluellyr
 Share

Recommended Posts

Hi,

I have a project that will be necessary to export/import and create/update pages and fields using the API without the end user action:

- It is possible to export pages or fields to a file and save that file using the Processwire API?

- It is possible to import pages or fields from a local or remote file (previous exported from other Processwire) using the Processwire API?

- It is possible to update pages or fields from a file using the Processwire API?

- Can the export/import functionalities give any help addressing these issues or it is necessary create all these functionalities from scratch?

 

Thank you and hoping to have your feedback.

Link to comment
Share on other sites

In a hurry, so answering quickly..

1 hour ago, bluellyr said:

It is possible to export pages or fields to a file and save that file using the Processwire API?

Yes. For fields and templates have a look at the method setImportData(). For pages, there's different ways. I'll let others chime in. Exporting pages example.

1 hour ago, bluellyr said:

It is possible to import pages or fields from a local or remote file (previous exported from other Processwire) using the Processwire API?

Yes, for pages, using previously exported JSON or ZIP and for fields using previously exported JSON and setImportData(). Examples of importing fields and templates from JSON.

1 hour ago, bluellyr said:

It is possible to update pages or fields from a file using the Processwire API?

Yes. How you do it depends on the fieldtype... (others will chime in here)

1 hour ago, bluellyr said:

Can the export/import functionalities give any help addressing these issues or it is necessary create all these functionalities from scratch?

Not sure I understand this fully, but yes, you can do everything from the API or using the GUI. For pages, the PagesExportImport is still experimental but it works fine (for me).

  • Like 2
Link to comment
Share on other sites

Sorry to say, but when you intend to migrate fields between installs be aware that the GUI import/export functions rely on ids rather than names. If the target is not 100% in sync with the source, you may end up correcting things in the database. This is particular true when it comes to Repeaters and the RepeaterMatrix. ...and do Option fields restore options properly when importing an exported page?

Until now I preferred to do this via API and run my own, application specific implementation.

  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...

@Autofahrn Yes that is one of my concerns.

The first approach to the implementation of the structure was to have a parent Processwire installation and to have some other children Processwire installations that in some how will mirror the structure of the parent (templates and fields). The templates and fields were not be edited on the children only the pages. For the pages we needed other process to maintain everything synchronised.

But this scenario is really difficult to maintain and synchronise and we have dismiss this approach and we are going to a central Processwire installation with an API and each child can CRUD using the API. We will need import/export functionality but with less or none uncertainties on the process since they will be executed on the central installation.

Thank you 

Link to comment
Share on other sites

6 hours ago, bluellyr said:

The first approach to the implementation of the structure was to have a parent Processwire installation and to have some other children Processwire installations that in some how will mirror the structure of the parent (templates and fields).

Sounds like the Multisite module could be a contender: https://github.com/somatonic/Multisite/

And you'll want to read the support thread to get an idea of the current status of the module:

 

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