Jump to content

Batch Child Editor


adrian

Recommended Posts

After test importing hundreds of pages in the last days I think BCE is a real time saver! Good job Adrian!

I still struggle with one feature though... since I have a lot of ProField Textareas to import to I have to use field pairings which works great, even with images, but the only location to configure field pairings are the parent pages.

This means I have to add each and every parent page to "Configurable Pages" in BCE settings. I can work with that but wouldn't make it more sense to make it template related? Since the template defines the fields to use then field pairings would be unique to a template?

I think I read something about this before in this thread but cannot find it anymore...

Link to comment
Share on other sites

On 16.11.2016 at 1:02 AM, adrian said:

Ok, the new version supports adding files and images. It works in both standard and field pairings modes. I haven't added support for descriptions/tags yet - will wait to see if anyone has the need.

It should work for local server paths to files/images, as well as remote urls.

Please test and let me know if you have any problems. 

While importing one image per field works fine I seem to be unable to import multiple images to an image field. The image field has no special setting and importing just one image works. 

I have tried with different separators(#, ##, \r, |) but to no avail. Strange, because this week I imported multiple values to an option field with no problems.

Did I miss something?

BCE 1.4.9 on PW 2.8.35 3.0.39

Edited by Klenkes
PW version change
Link to comment
Share on other sites

  • 2 weeks later...

just asking... could it be that it is not yet supported to import multiple images(separated with a delimiter) to an image field?

I went through the module code(not that I understand a lot of it but getting better) and couldn't find any reference to importing multiple images.

Link to comment
Share on other sites

Hi @mel47 and @Klenkes - sorry for the delay in dealing with your issues. I have implemented some fixes, but things are not well tested yet, so I am just going to attach the updated version to this post.

On 12/7/2016 at 7:26 PM, mel47 said:

Again me... I have a problem I couldn't understand. I created my CSV file with " " in each column :

"Article in Metabolic Brain Disease-Bosoi-2009";;"Accepted article";"Publication";2008-12-29 18:12:48;;"<p>Latest paper was published in Metab Brain Disease</p>";"<p>Latest paper was published online December 23<sup>rd</sup>.</p>";;;"Bosoi et al.-2009-MetabBrainDis"

The last field is Page. Everything imports fine (no error), but last field is imported as

Bosoi et al.-2009-MetabBrainDis"

Why it keeps this extra " ?

Thanks

Melanie

@mel47 - can you please test the attached version and let me know if it fixes it. I inadvertently deleted my line ending fix in a recent commit. It has been reinstated so hopefully that will take care of this for you.

 

On 12/8/2016 at 1:01 AM, Klenkes said:

After test importing hundreds of pages in the last days I think BCE is a real time saver! Good job Adrian!

I still struggle with one feature though... since I have a lot of ProField Textareas to import to I have to use field pairings which works great, even with images, but the only location to configure field pairings are the parent pages.

This means I have to add each and every parent page to "Configurable Pages" in BCE settings. I can work with that but wouldn't make it more sense to make it template related? Since the template defines the fields to use then field pairings would be unique to a template?

I think I read something about this before in this thread but cannot find it anymore...

@Klenkes - I am not against this idea because I can understand the problems you are having. Unfortunately I think that would be a huge change to the module. I'll definitely think about it, but I can't promise a timely resolution for this I'm afraid - hope you understand!

 

On 12/19/2016 at 2:51 AM, Klenkes said:

just asking... could it be that it is not yet supported to import multiple images(separated with a delimiter) to an image field?

I went through the module code(not that I understand a lot of it but getting better) and couldn't find any reference to importing multiple images.

Yeah you were right - I never implemented the multiple values separator logic for files/images. The attached version should take care of this. I have tested with field pairings, but not without at the moment. Please let me know how it goes for you.

 

 

Edited by adrian
Removed attached version because it's now on Github
  • Like 1
Link to comment
Share on other sites

1 hour ago, adrian said:

 

@mel47 - can you please test the attached version and let me know if it fixes it. I inadvertently deleted my line ending fix in a recent commit. It has been reinstated so hopefully that will take care of this for you.
BatchChildEditor.zip

Perfect! Works as expecting when CSV is pasted.

Thanks again!

  • Like 1
Link to comment
Share on other sites

On 21.12.2016 at 2:43 AM, adrian said:

Yeah you were right - I never implemented the multiple values separator logic for files/images. The attached version should take care of this. I have tested with field pairings, but not without at the moment. Please let me know how it goes for you.

Ahhh...  new module name: ImportingMadeEasy! Absolutely great!
I tested with field pairing and it works without any flaws.

And no rush with the  "Configurable Pages" issue, or even if it is no doable. The way BCE now works is absolutely great and I can plan to migrate a few websites to PW.

Many thanks and have a great christmas holiday.

  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...

Hey all

This module works great. But, I do have one problem. I need to export most of the data on the website to a csv, but the site is in multiple languages available. And I need all the available languages in the same csv. Is there any option to fix this in the module or are there plans for this module to add an export option for multiple languages?

-Edit-

The website I currently use is build like this:

  • Products
    • Category
      • Product
      • Product
      • Etc...
    • Category
    • Etc.

Is it possible to export a csv file containing all the categories together with the products? Something like pages and sub-pages...

 

Thanks in advance,

 

Harmen

Link to comment
Share on other sites

6 hours ago, Harmen said:

And I need all the available languages in the same csv.

Hi @Harmen - how do you envision all the languages being formatted in the CSV - using a "|" or some other separator, or do you have some other approach in mind?

 

6 hours ago, Harmen said:

Is it possible to export a csv file containing all the categories together with the products? Something like pages and sub-pages...

Currently BCE only supports direct children of a page. I am not sure how to come up with a standardized approach for handling sub-pages/grandchildren in CSV format. Perhaps if you could explain (or provide an example) of how you'd like the CSV to look I could implement it, or you could provide a PR :)

  • Like 3
Link to comment
Share on other sites

Some of my thoughts but I really don't know if it's feasible or too much error-prone.

For sub-levels:

Having a new field (in the CSV): sub-levels. I discovered this approach in the Menu Builder module. However, since this field doesn't exist in template, it could be confusing if we forget to add it when add or replace data.

For multi-language:

According to me, it shouldn't use | since they are already use for many images/pages. Furthermore, I used CSV in Excel to fill quickly in column format, so I need different CSV fields. I guess the best option is having for example: body_en;body_fr. But I'm not sure how to order the CSV since there is maybe non-multi-language fieldtypes in the template. And/or, since not applicable to CSV import-export, to add data, it could be a multilanguage area (it used when you edit a ML option's fieldtypes).


But I have no idea how those things works, so I let you decide how good they are...

  • Like 1
Link to comment
Share on other sites

Hey @adrian

Thanks for your reply. I've asked my contractor how the csv file must be classified. He gave me an example which you can see in the attachment.

There is one product in the attachment, but the same needs to happen for all products and categories. Languages are seperated per column. Each product in a row, Same for categories. I hope this helps you, I will also think for a solution in the code of the module altough I don't have that much experience with exports to csv formats.

Note: With my 18 yrs I expect you're way better than me, but I will give it a try to think about it ;)

 

-Edit-

I wrote a module to get the categories and products (and more stuff) from the prestashop database and import the data in Processwire. What would be easier, write another piece of code in my module/or new module to get the data out of the database and directly import it to a csv file, or just make a csv file from the data in the Processwire fields?

 

Sorry for so many questions, still a bit newbie here I guess :D

example.xlsx

Edited by Harmen
Additional information
  • Like 1
Link to comment
Share on other sites

@adrian

Found a way to get the grandchildren into the csv file. You can find my code in the attachment. But I don't get all the data from the fields like image links and more. Maybe I've missed something? I guess it doens't get all the data, because the labels are different for the categories and products

-Still searching for multiple language-

 

ProcessChildrenCsvExport.module

Link to comment
Share on other sites

Hi Harmen,

Sorry it's taken me a while to respond to your post. I took a quick look at the code you added and I think all that logic needs to end up in a function that we can call for children and then again for grandchildren, rather than duplicating.

I am honestly wondering if this is a good fit for BCE because I am not sure that everyone will want the same formatting for grandchildren, although honestly I don't know how it looks yet, but grandchildren can have different templates/fields which would surely make a mess in a CSV?

I wonder if you'd be better off with something like a custom implementation using PHPExcel (https://github.com/PHPOffice/PHPExcel).

I do however agree with adding options for multilanguage support for exports. I don't expect this should be too difficult if we take the approach of a separate column for each language version of each field. 

Cheers,
Adrian

  • Like 1
Link to comment
Share on other sites

Hi Adrian,

No worries, it's ok. Good idea, functions are always good to use, less code easier to call.

I understand not everyone wants the same. Maybe an inputfield with radio buttons at the module info to check if they want to export the grandchildren too can fix it. You're right. It would be a mess, even my grandchildren pages don't have the same name as the fields of the child pages while the fields have the same type.

I will take a look at PHPExcel next week.

If you need any help during the development of multiple languages - message me ;) I will also search for a solution.

Regards,

Harmen

  • Like 1
Link to comment
Share on other sites

I am using this on one of my sites to export csv via the api and it all works fine except I am getting some spurious code at the start of each csv file - i.e:

<script>
var config = {"urls":{"root":"\/pw\/"

</script>

Can anyone help with where this might be coming from, I've done a search everywhere I can think of and can't find it.

Many thanks

Link to comment
Share on other sites

On a multilanguage install if pages doesn't have the title filled for the user's language, BCE shows the title on the default language. This is good, but can be misleading because one can think that the title is filled but actually it's empty.

I could imagine a solution to notify the user about it, eg. like this:

bce-default-title.png

Perhaps there's a better solution, this was the first that came to me.

Link to comment
Share on other sites

@Hantsweb - any chance you have the SessionHandlerDB module installed?

@tpr - I wonder if in reality this should come under an overhaul for BCE to add multi-language support in general - maybe the edit interface needs tabs to make it possible to edit titles in all languages? Trouble is that I am really going to start running out of time for major module changes here. Anyone up for putting together a PR?

 

Link to comment
Share on other sites

I think what @tpr says is right, I guess it could be super complex. 

I am also still a newbie in Processwire and don't know that much about programming as tpr, adrian etc etc

I am always available if anyone needs some help. In a few weeks my internship is over and school starts again for me, hoping to have time left then for PW...

  • Like 1
Link to comment
Share on other sites

@tpr  - it's implemented, although a little differently because I didn't want "default" taking up so much space in the input. I went with a warning icon and outside of the input so I could add a title tag to it.

I am checking if the "FieldtypePageTitleLanguage" module is installed before checking if there is a title in the user's language. Maybe one of the ML gurus can tell me if there is a better approach:

$this->modules->isInstalled("FieldtypePageTitleLanguage") && !$cp->title->getLanguageValue($this->user->language)

Let me know if this suits your needs.

Screen Shot 2017-01-10 at 4.34.49 PM.png

  • Like 2
Link to comment
Share on other sites

Thanks, working fine here. As for the snippet I think it's OK too. I usually check for multilanguage with something like this though I'm not sure it's a better approach.

if ($this->languages && $this->pages->find('template=language, check_access=0')->count() > 0)

 

  • Like 1
Link to comment
Share on other sites

6 hours ago, tpr said:

Thanks, working fine here. As for the snippet I think it's OK too. I usually check for multilanguage with something like this though I'm not sure it's a better approach.


if ($this->languages && $this->pages->find('template=language, check_access=0')->count() > 0)

 

Thanks - I ended up changing a little anyway. I went with:

$titleMultiLanguage = $this->modules->isInstalled("FieldtypePageTitleLanguage") && $this->fields->get('title')->type == 'FieldtypePageTitleLanguage';

because I figured in this case we need to be sure that the "title" field type is actually set to "FieldtypePageTitleLanguage" or we'll get a non object error when I try to use getLanguageValue() on it. Sound ok?

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