Jump to content

PW 3.0.64: Page export/import details


ryan
 Share

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
Link to comment
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
Link to comment
Share on other sites

  • 1 month later...

@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
Link to comment
Share on other sites

  • 7 months later...
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.

Link to comment
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. ?

Link to comment
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?

Link to comment
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
Link to comment
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
Link to comment
Share on other sites

  • 2 weeks later...
  • 2 months later...

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

 

 

Link to comment
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.

Link to comment
Share on other sites

  • 4 years later...

@ryan While working on my pagebuilder module I also figured out that the meta data from $page->meta() is not exported with the page. This is a real bummer, because my page builder is storing all the styling information in the corresponding $page->meta and it would be nice to use this core feature to export that data as well

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