Jump to content

Module: Import Pages from CSV file


ryan

Recommended Posts

And are you trying to map to those fields? Also, if you are trying to set the page id and url, then this is not going to work. PW creates its own page id and url once when you do the import. You can update the url, but not out of the box using this module unless something has changed since last time I used it.

Link to comment
Share on other sites

  On 8/26/2016 at 12:35 PM, RyanJ said:

And are you trying to map to those fields? Also, if you are trying to set the page id and url, then this is not going to work. PW creates its own page id and url once when you do the import. You can update the url, but not out of the box using this module unless something has changed since last time I used it.

Expand  

What should my csv header be to just upload pages at the minimum? 

 

edit: I found the answer to my question. 

 

title,myfield1,myfield2
titleA,myfield1_value,myfield2_value
titleB,myfield1_value,myfield2_value
titleC,myfield1_value,myfield2_value
Link to comment
Share on other sites

  • 1 month later...

Don't know if it was only my data but when using a checkbox fieldtype, the checkbox was checked even if the value was 0 so needed to go through all pages to uncheck those that shouldn't be checked.

However, added the 'FieldtypeOptions' and it worked perfectly by having the correct value selected.

Also, as other mentioned, would be nice to have the module support multi-language site. If the French title could be populated at the same time as the English title with also the status checked, it would help enormously.

This also goes for the PageActionExportCSV module to be able to export at the same time the English and French title.

  • Like 1
Link to comment
Share on other sites

  • 1 month later...


I am using ImportPagesCSV to import and update images for some product pages.

Each CSV line contains the title field of a page and the URL of an image to add to this page.

While this basically works just fine, I need to change the behaviour in some aspects:

  1. prevent the module from creating any new pages (only add images to existing pages)
  2. any existing images with identical name should be overwritten (replaced)
  3. the image just added should become the first image (index 0) in the image field

For 2) I tried setting the "Overwrite existing files" option in the image field settings, but that did not help.

Anyone to give me a hand, please?

My programming skills seem too limited to identify the right places in the module's code, I'm afraid...

Link to comment
Share on other sites

I don't think this module has the option for overwriting, but this one does: 

It's a lot more than just a csv to page module so the config settings may seem overwhelming at first, but it should do what you want. You'll want to enable Update mode and maybe even define field pairings in the csv import settings. You may also want to set up config settings for specific pages.

Anyway have a stab at it and let us know if you need help - probably best to respond in the module's support thread rather than here.

 

  • Like 3
Link to comment
Share on other sites

  • 3 months later...

For pages not using the title field (which you can achieve with: Setup > fields > title > advanced tab > turn off global flag), you can do a couple of modifications:

Do this commenting out in importPage function:

/*if(!$page->name) {
$this->error("Unable to import page because it has no required 'title' field or it is blank.");
return false;
}*/

Then in importPageValue you can construct a naming scheme or just use the id (after the else statement):

$page->set($name, $value); 
$page->name = $page->id;
  • Like 2
Link to comment
Share on other sites

  • 4 weeks later...

@arjen , grab that! The whole module is not so long, so it's possible to place it right here.

@ryan , if You'll have some time, please review my mod. It will take a minute, the mod is really simple. Thanks in advance!

  Reveal hidden contents

 

ImportPagesCSV.module

Edited by theoretic
spoiler and module file added
  • Like 1
Link to comment
Share on other sites

  • 4 weeks later...
  • 1 month later...
  • 3 months later...
  • 1 month later...
  On 5/31/2013 at 2:06 PM, doolak said:

Ok, got it - and I have to say once again: "Thanks, Soma!"

Here the thread and the post with the solution:

http://processwire.com/talk/topic/1272-new-page-nav-in-admin/?p=11276

The important part is the setting of the moduls permisson:

public static function getModuleInfo() {
		return array(
			'title' => 'Import Tabelle als CSV', 
			'version' => 103, 
			'summary' => 'Import CSV files to create ProcessWire pages.',
			'singular' => true, 
			'autoload' => false, 
			'permission' => 'page-edit'
			);

In this way the modul is editable by a non-superuser and can be accessed through the top navigation.

Expand  

Hello,

I did (or I believe) it correctly but this function is still only visible to superusers. Version 2.7.

Do I need to change something else?

Thank you very much in advance! !!

Link to comment
Share on other sites

Hello,

this module is great and I was wondering:

  • Is it possible to use this module inside a template via API functions?
  • Is it possible to set a cron job to automate the import?
  • Or would you recommend for this job to install an package via composer and to write your own logic?

I am looking forward for your suggestions. :)

Regards, Andreas

Link to comment
Share on other sites

  • 2 months later...

Not sure about SQL schemas, but you should take a look at these options:

https://github.com/adrianbj/ProcessMigrator/blob/master/README.md

https://processwire.com/blog/posts/processwire-3.0.68-and-more-on-page-export-import/

Importing and exporting fields and templates has been in core for a while now. The format which is used is JSON. You could just as well write JSON yourself for automatic creation. The import feature is labelled "beta" though - perhaps test it out on a dev system first and see how it goes.

  • Like 2
Link to comment
Share on other sites

Thank you dragan!

So there is no such module?

I'm not sure. If I have to write it myself, I'm probably going the direct way and create the templates and fields directly.

new Fieldgroup();
new Template();
new Field();

JSON seems like an unnecessary extra layer here.

Thank you.

Link to comment
Share on other sites

  • 1 month later...

for multilingual sites, what is the process for importing from a single table that contains fields in 2 languages?

::mytable

---title_en

---title_fr

---description_en

---description_fr

 

I need to import 300k records and before I proceed I want to make sure how to do it, thanks!

 

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
×
×
  • Create New...