Jump to content
bluellyr

Questions: Export and Import pages or fields using the API

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.

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

@kongondo thank you for your time and for your reply. It gave me a lot of to dig into. Many thanks for the links and examples.

 

Share this post


Link to post
Share on other sites

@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 

Share this post


Link to post
Share on other sites

Indeed, sounds complicated. But since you can do anything using the PW API, I don't see a reason why this shouldn't work with a custom solution. But there probably is no module which could be used out-of-the-box.

Share this post


Link to post
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:

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...