Jump to content

import at once pages with child with sub


bwakad
 Share

Recommended Posts

I know of the import module CSV / paste data.

Basically it let me select a parent and required (in my case) a template.

But how to import to make, 12 pages, each with 15 childpages, and inside that about 20 subpages.

title for every page. But pages, childpages and subpages have different template.

Now, I need to do the whole routine for (12x15) minimum. Exhausting!

Link to comment
Share on other sites

I used those frequently for adding or changing quickly. But I am more looking for a way to bulk import a large quantity.

Say for example Spain has 52 provinces (title only), and each province can have about 20+ childpages (title only).

So even with CSV (pasting) I would need to do the same thing 52 times:

1. select template

2. select parent (wrestle through the tree)

3. go to my file

4. select and crtl c

5. go back to PW

6. scroll down again

7. click to open

8. ctrl v

Can you imagine with batcher or the other one you mentioned, I would need to type and use TAB.

Isn't there some automation to perform?

Link to comment
Share on other sites

If i understand correctly, you are trying to create a sequence of, 12 + (12*15) 180 + (180*20) 3600 = 3792 pages??

Should, for some reason, you need to repeat this often i would try to create your own specialized import script. There should probably be some mechanism in there to prevent memory issues and time-outs as well.

Link to comment
Share on other sites

It really depends on what format you already have them in. A custom import script could be fairly easy to write making use of http://php.net/manual/en/function.str-getcsv.php. Take a look at the code that runs Ryan's CSV importer to figure out what you'll need to do.

Once you are done though, I would encourage you to use Migrator to export as a page list that can be shared with others via: https://github.com/adrianbj/ProcessWirePageLists

You'll see I already have a country set and some state sets for a few countries.

Link to comment
Share on other sites

@sinnut:

You right about that. I have thought about how to get to a destination Country/Province/City - And it's getting ridiculous amounts of pages, just for that.

But I do not see any other way. And if I think about PW - were a page is not really a physical page, it will be fine I guess. Considering people store this in database all the time.

@adrian:

thanks for the links, I am not sure about the link to php, but I think the module is good to use. If you are interested, I have a json format of brazil, up until cities.... really huge!

Link to comment
Share on other sites

Interesting. In my own little country, The Netherlands, there are already around 6500 settlements (cities, towns, villages etc.). If you were to take that to continental or even bigger scale you would be talking about possibly hundreds of thousands items. These could indeed be all pages in PW, no problem. It's important to find the most efficient and useful way of structuring the PW tree, specific to the project.

Link to comment
Share on other sites

Interesting. In my own little country, The Netherlands, there are already around 6500 settlements (cities, towns, villages etc.). If you were to take that to continental or even bigger scale you would be talking about possibly hundreds of thousands items. These could indeed be all pages in PW, no problem. It's important to find the most efficient and useful way of structuring the PW tree, specific to the project.

lol. the keyword here is: province and municipal - or in dutch : Provincies en Gemeenten (towns and villages get overrated)...

Example, if I send a letter, I would use the Gemeente, not the part like town / village. YES: Almere NO: Almere-buiten, almere-binnen, almere-haven, etc.

As far as I know, there are about 403 gemeenten in NL.

Link to comment
Share on other sites

I am curious to know what the format is for the json:

parent / childpage / subpage

all by title

Take a look at one of the files in the PageLists repo on Github. Paste the contents into: http://json.parser.online.fr/beta/ to make it easier to view. It includes info on page title, name, sort order, parent, template etc. It also includes the info to create any required fields - eg country/state codes etc.

Link to comment
Share on other sites

Okay, that's cool. I have taken the liberty of pasting part of your data to see how it's done.

I am not sure about the parent name (empty),

I think status and sort are PW build in.

I believe 'sort' is the order in which it appear in the tree.

Will try to import this as json to see what happens....

- EDIT - after some errors on my side (template name / parent name) This one is a great module!

If there was a convention of names, everyone could export and post it on the git to be re-used for import.

For instance, if everyone say "countries" for the parent page, and "country"  or "country_template" for the children, things were easy to share in this community. Like JSON, functions among others...

{"pages":[
{"name":"countries",
"parent_name":"",
"page_template":"countries",
"status":1,
"sort":6,
"sortfield":"title",
"data":{"title":"Countries"}},

{"name":"andorra",
"parent_name":"countries\/",
"page_template":"countries_items",
"status":1,
"sort":0,
"sortfield":"sort",
"data":{"title":"Andorra",
"iso_2":"AD",
"iso_3":"AND",
"iso_numeric":"20"}}
]}
Link to comment
Share on other sites

- EDIT - after some errors on my side (template name / parent name) This one is a great module!

Did you try pasting just that snippet into Migrator or did you do it properly and import using the "Shared JSON Packages" option from within the Migrator import process?

If the former, then I am not surprised because that JSON snippet doesn't contain everything needed. If the latter, could you please share the errors you got?

Link to comment
Share on other sites

lol. Just looked up something I frequently use upon normal mail....

postal code / city : 1338 AM 30, Almere

or sometimes: 1338 AM 28

or streetname 22 Almere

Which all represents Almere-Buiten and get's delivered by our good employees of postal offices!

Link to comment
Share on other sites

Did you try pasting just that snippet into Migrator or did you do it properly and import using the "Shared JSON Packages" option from within the Migrator import process?

If the former, then I am not surprised because that JSON snippet doesn't contain everything needed. If the latter, could you please share the errors you got?

Adrian, your module is good.

- EDIT - on pasting JSON

It was because I pasted the snippet above but forgot to change template name.

I chose, Import > Append > Paste Json. And received Invalid value sent to Page::setTemplate

Only thing was, it did not remember the entry, and no back button.

Had to choose again: setup > migrator. Then do it all over.

When I changed the template name (from andora) it all works fine... although I chose parent "countries" which created a "countries" as child.

So your module is working great!

- EDIT - on shared JSON

On shared JSON, one thing... it says I have to select 1 level up. Confusing.

countries > US > still empty here

US-states > state-names (imported correctly)

when I redo everything and choose as parent : countries > US

I received SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'alabama-1987' for key 'name_parent_id'

which is strange since this should be assigned a new ID.

Link to comment
Share on other sites

Glad to hear it's working, although it was never designed to import parts of JSON files like that. You shouldn't have to do anything with renaming anything. Try again and grab the countries list from the shared packages option and import it to Home as the parent, or some other parent page, rather the countries and you won't get the duplication problem. Maybe that needs to be better documented.

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