Jump to content
ryan

PW 3.0.64: Page export/import details

Recommended Posts

Quote

In one case, developing a login, authentication and download system

Quote

developing a custom module for managing Facebook logins, pulling data from Facebook, and connecting them with ProcessWire accounts

@ryan, stuff like this is super-interesting to us aspiring devs and I for one would give my right arm to take a peek at your code and see how an expert approaches these things. It would be a really great learning opportunity. In general, would your client contracts allow you to share snippets of project code with the community? Would you be comfortable doing that? (not expecting you to reveal all your secrets!)

Not in any way that would require you to invest time in making things plug-and-play or offering support for them - just dropping some interesting bits as Gists on Github. A possibility?

  • Like 8

Share this post


Link to post
Share on other sites
Quote

In general, would your client contracts allow you to share snippets of project code with the community? Would you be comfortable doing that? (not expecting you to reveal all your secrets!)

I actually think for this module the client expressed interest in us releasing it available for others to use once it's finished. I will confirm though. I used the process outlined on this page (link) to do a lot of it, though admittedly there was also a lot of stuff to figure out with some trial and error. 

  • Like 14

Share this post


Link to post
Share on other sites

@ryan thanks a lot! :)

I had a little use case where I couldn't resist to use the new feature. It was only for pages with text fieldtypes. I used two little bootstrap scripts to export & import some pages.

export.php

Spoiler

<?php namespace ProcessWire;

// export from site 1
include( __DIR__ . '/index.php');
$fn = 'd:/tmp/dump.txt';

$pa = $pages->find('template=hilfecontainer|hilfeeintrag|hilfeleerestemplate, include=all');

$pe = new PagesExportImport();  // ImExport Object
$dump = serialize($pe->pagesToArray($pa));
file_put_contents($fn, $dump);  // save serialized Pages Array

 

 

import.php

Spoiler

<?php namespace ProcessWire;

// import into site 2
include( __DIR__ . '/index.php');
$fn = 'd:/tmp/dump.txt';

$dump = file_get_contents($fn);
$pa = unserialize($dump);       // get back the Pages Array

$pe = new PagesExportImport();  // ImExport Object
$pe->arrayToPages($pa);         // create the new Pages :)

 

 

  • Like 13

Share this post


Link to post
Share on other sites
On 7/21/2017 at 11:29 AM, horst said:

I had a little use case where I couldn't resist to use the new feature. It was only for pages with text fieldtypes. I used two little bootstrap scripts to export & import some pages.

Hi @horst. Why did you have to bootstrap ProcessWire? Were both sites not ProcessWire 3.x sites? Thanks.

Share this post


Link to post
Share on other sites

The only reason for bootstrapping in this usecase was, that I prefer this for administrative tasks. The pros are: cli access directly gives you superuser rights without extra login steps; it is very fast by copying the bootstrap script around in my local filesystem; It also works from more levels above the webroot; ...

HTH to clarify. 😀

Share this post


Link to post
Share on other sites
2 hours ago, horst said:

The only reason for bootstrapping in this usecase was, that I prefer this for administrative tasks. The pros are: cli access directly gives you superuser rights without extra login steps; it is very fast by copying the bootstrap script around in my local filesystem; It also works from more levels above the webroot; ...

HTH to clarify. 😀

Thanks. I'm a bit confused though. $pages should not work in a bootstrap context (you need wire('pages') or equivalent, so how come you are using that, or you'd defined $pages earlier?

Share this post


Link to post
Share on other sites
4 hours ago, kongondo said:

$pages should not work in a bootstrap context (you need wire('pages') or equivalent,

Not anymore!

Can't find where it was announced, but all pw variables have been available for quite some time now.

  • Like 2

Share this post


Link to post
Share on other sites
6 minutes ago, adrian said:

Can't find where it was announced, but all pw variables have been available for quite some time now.

Thanks.

I feel like I'm light years behind! That's what happens when you are a late adopter!

  • Haha 1

Share this post


Link to post
Share on other sites

Ha, I'm a late adaptor in so many parts. Feels really good to be one of the early birds in this special case. :P

Share this post


Link to post
Share on other sites

Just cross-referencing: I've ported the export functionality into a module and class for exporting ProcessWire 2.x sites in a format compatible with importing into ProcessWire 3.x using PagesExport/Import.

 

  • Like 3

Share this post


Link to post
Share on other sites

Little question here:

So the export exports fields and references to the files, which will then be downloaded via http by the import.
Why did you decide not to export the template file of the selected page(s)?
-- My first thought was: Cool, now I can develop a new template in a dev-enviroment, maybe also changing some other old pages, and deploy everything in one step to the production... 

 

 

Share this post


Link to post
Share on other sites
3 hours ago, ocr_b said:

Little question here:

Is this question directed to me?

Welcome to the forums.

Share this post


Link to post
Share on other sites
2 hours ago, kongondo said:

Welcome to the forums.

Thanks, been around here for some time, but mainly reading 😉

2 hours ago, kongondo said:

Is this question directed to me?

This question is directed to everybody working on the Page Export/Import Core Module.
(And I could not find a better place to post this question, or should I open a new topic?)
I just wondered if and why if its not including templates directly, although its including fields.
Maybe there is a downside / use-case I do not see at the moment.

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