Jump to content

Batch Child Editor


adrian

Recommended Posts

On 6/20/2018 at 9:22 PM, mel47 said:

OMG I finally find it! ? A little bit not user-friendly, unfortunately. So after activating this configurable settings page, I finally discovered under "settings" a "Batch child editor setting". After going back to my BCE tab, the page selector is now there. Strangely when I removed this specific page from configurable pages (just for testing), the settings section disappear, however the page selector/fields to export are still sticking to my export CSV in BCE tab.

Thanks for your patience!

 

 

Yeah I have the same problem. Except no matter what settings I put in config I can't get options to appear and when I export the csv I get a completely blank file. It looked promising. Maybe it's not compatible with pw 2.8.62

Link to comment
Share on other sites

58 minutes ago, digitex said:

Yeah I have the same problem. Except no matter what settings I put in config I can't get options to appear and when I export the csv I get a completely blank file. It looked promising. Maybe it's not compatible with pw 2.8.62

Can you please post some screenshots of your config so we can check things?

Link to comment
Share on other sites

On 8/3/2018 at 3:17 PM, adrian said:

Can you please post some screenshots of your config so we can check things?

Hey Adrian, I'm sure I must have had it config'd wrong but I needed something quick so I just went with a front end option. I uninstalled already.

Link to comment
Share on other sites

Hi, guys!

I'm currently building a product catalog .CSV-file to be imported by BCE. I have a massive amount of entries (product highlights) to import and I want to use ProFields Table since it does support multi-language.

Is there any way BCE could support ProFields Table with a single column containing a multi-language ckeditor textarea?
I wanted to add rows to the table field via row1content|row2content|row3content... in the .CSV-file.

The multi-language part isn't essential.

TableRow isn't supported afaik - at least pairing the field (mytablefield.mycolumn) isn't working.

I looked at @adrian's Table CSV Import / Export Module but this is, at least in the admin, only for populating single pages. Maybe I can build an import script using the Table CSV Import module, match and populate the pages imported via the initial .CSV-file, but it would be a lot better to manage if it could all be done with the "product catalog" .CSV-file that also creates the product pages - and better for future updates by me and editors.

Anyone has an idea? Many thanks in advance!

Best

  • Like 1
Link to comment
Share on other sites

Hi @masslevel - Table field support could certainly be added to BCE. It already supports other multi-value field types using a separator like: |

You could add code for Table fields here: https://github.com/adrianbj/BatchChildEditor/blob/339624b0a14a9f403ae73b37a08f3e0f5f8d6136/BatchChildEditor.module#L1608

You should be able to find the code you need here: https://github.com/adrianbj/TableCsvImportExport/blob/a4e6ad668fd92f668546ba62cf726d29871b6d05/TableCsvImportExport.module#L341

If you can add this, I'd be happy to accept a PR for BCE.

 

  • Like 1
Link to comment
Share on other sites

3 hours ago, adrian said:

Hi @masslevel - Table field support could certainly be added to BCE. It already supports other multi-value field types using a separator like: |

You could add code for Table fields here: https://github.com/adrianbj/BatchChildEditor/blob/339624b0a14a9f403ae73b37a08f3e0f5f8d6136/BatchChildEditor.module#L1608

You should be able to find the code you need here: https://github.com/adrianbj/TableCsvImportExport/blob/a4e6ad668fd92f668546ba62cf726d29871b6d05/TableCsvImportExport.module#L341

If you can add this, I'd be happy to accept a PR for BCE.

 

Thanks for your reply @adrian and your confidence in my very basic coding skills ;-). I would love to do a PR but I don't even know how to start in integrating your code. Sure I can try copy-pasting, but I guess it takes a bit more. I will certainly try and see how it goes since I definitely need / would love to have that feature.

Link to comment
Share on other sites

3 minutes ago, masslevel said:

Thanks for your reply @adrian and your confidence in my very basic coding skills ;-). I would love to do a PR but I don't even know how to start in integrating your code. Sure I can try copy-pasting, but I guess it takes a bit more. I will certainly try and see how it goes since I definitely need / would love to have that feature.

Have a go and if it goes well, great, and if not, I'll try to find some time to pick up where you get stuck and get it working.

  • Like 2
Link to comment
Share on other sites

I modified Batch Child Editor to work with my use case of not requiring title field for templates.

Commented out:

if(!in_array('title', $convertedFieldPairings)) {
    if(in_array('add', $this->data['pageSettings'][$pp->id]['editModes']) || in_array('replace', $this->data['pageSettings'][$pp->id]['editModes'])) {
        $this->error($this->_("You must include a \"title\" field in the CSV Field Pairings, unless the only available modes are \"Edit\" and \"Update\"."));
    }
}

To create a new naming scheme, changed row 1560 to:

$this->setPageTitleOrName('name', trim($childTemplate . "-" . $this->wire('sanitizer')->text($childFieldValue) . "-" . $x), $np, $newPage);

After

//populate numeric array of field names
$fieldsArray = array();
foreach($np->fields as $f) $fieldsArray[] = $f->name;

I added

$this->populateField($np, $fieldsArray[$i], $childFieldValue);

so it would not leave the first field blank.

Btw. there are new releases of ParseCsv: https://github.com/parsecsv/parsecsv-for-php/releases
It has received a big renovation, PHP 7.2 support etc. I was unable to make it work, but I did not sacrifice much time on it.

Another library to consider is https://github.com/thephpleague/csv

  • Like 1
Link to comment
Share on other sites

Hi @Beluga - do your changes break any existing workflows? In other words, could I incorporate your changes without any issues?

Thanks for the link to the updated parsecsv - I am curious what wasn't working when you tried to update? BTW - I am using the old version with PHP 7.2 and I don't think I have come across any issues yet - did you?

I did look at thephpleague/csv, but at the time it wasn't working as I needed, although I don't remember what the issue was.

Link to comment
Share on other sites

14 hours ago, adrian said:

Hi @Beluga - do your changes break any existing workflows? In other words, could I incorporate your changes without any issues?

Thanks for the link to the updated parsecsv - I am curious what wasn't working when you tried to update? BTW - I am using the old version with PHP 7.2 and I don't think I have come across any issues yet - did you?

I did look at thephpleague/csv, but at the time it wasn't working as I needed, although I don't remember what the issue was.

Well, my custom naming thing is something that you should not incorporate ? So I think the naming probably needs some work.

Re: parsecsv - maybe it was my inability to use it without Composer.

I have not run into issues with PHP 7.2.

  • Like 1
Link to comment
Share on other sites

2 hours ago, Beluga said:

Note that I only took into account the code path which did not deal with "field pairings". This is because I was unable to locate any field pairing feature in the BCE interface.

Field pairings is only available when you define configurable pages - then in the Settings tab for those page you can setup the field pairings.

Link to comment
Share on other sites

  • 3 months later...
5 hours ago, hansv said:

Hi

Is it possible to import into repeater fields?   

hansv

Not really as is because there are too many issues with a repeater's multiple subfields and multiple items. How would you format the csv file to support this? 

BCE does support multiple value fields though like Page reference, multiplier, etc with a multiple values separator in the csv. I guess it might be possible to use columns for the subfields and rows for the repeater items, but I think this is really of out the scope of this module. I think you'd be better off building a custom solution for your needs, maybe built on top of the AdminActions module.

Link to comment
Share on other sites

  • 1 month later...

I'm not sure if it's just me, or if I've discovered a bug (or maybe I misunderstand the way "overwrite names" is supposed to work).

When I enable "overwrite names" in the module, and then go to any parent page that has children pages, I can't seem to edit names in batch mode. Of course I can do it when I open the modal, but I don't get a text input field for page-names the same way I get it for page titles.

Then I thought: Maybe this feature is supposed to change names when I change the title (like PW does when you create a page). But that is also not the case. I have changed a page title, but the name remained the same.

Am I missing something? Can somebody else confirm this behaviour?

BCE v. 1.8.4, PW 3.0.99, PHP 7.0.32, UIKit Admin Theme
Updated BCE ust now to v. 1.8.14, but it still behaves the same.

batch-child-editor.thumb.PNG.028b0d92c31995174c39f7edff8d8a62.PNG

page names are not editable

 

bce-settings-names.thumb.PNG.f585bdf55da0fa4edc9434f4cb58f340.PNG

settings

bce-settings-enabled-templates-etc.thumb.PNG.c62e05a8c943b23e496ba975210021c7.PNG

all templates and pages are enabled

Link to comment
Share on other sites

Yes, it's about automatically changing the name to match the new title.

Not sure - it's working here:

image.png.0b015688ce4d18a46d8ac07185192cd3.png

Change title and save:

image.png.6cbfc39e94e9c1ba7f124b16a35be210.png

EDIT: I just figured out that there is a bug when the "Allow user to change "Overwrite Names" setting is checked. Can you confirm that it works for you without this? I'll fix shortly.

PS - any idea why those table headings have outlines?
 

Link to comment
Share on other sites

Actually, I've had another look at this and actually it seems to be working just fine. Given that you have the "Allow user to change "Overwrite Names" setting checked, are you then actually checking this in the edit interface:

image.png.bd9bbd3f95c1bafc374836a16388bd76.png

Link to comment
Share on other sites

@adrian thanks for your feedback!

I have to take another test-drive tomorrow. But a thought just crossed my mind: In my case, the client has cloned pages several times, but did not edit the page-names. So he edited the page title, but kept the page-name untouched. This results in page-names such as "original-page-slug-1-2-3" etc.

When I used BCE today and "pseudo-edited" the page-title (from same to same - and hit "save"), nothing was changed in the page-name. Perhaps your code checks if old and new page title differ, and only applies the change if there really was one...

re: table heading outlines
no idea atm - I guess it has to do with me customizing all sorts of stuff with the admin theme (and maybe with AdminOnSteroids, which is also installed here and active). Will also check tomorrow.

 

Link to comment
Share on other sites

43 minutes ago, adrian said:

any chance you have the Settings tab hidden?

the settings tab in page-edit? No.

44 minutes ago, adrian said:

If the title isn't changed, nothing gets updated.

Makes sense.

45 minutes ago, adrian said:

do you have PageRenameOptions installed?

No. In fact, I just learned about it now. I will install it and give it a try.

Link to comment
Share on other sites

I just installed it and made a test. I noticed two things:

  1. A page-title "Minitab (Statistik / Datenauswertung)" was converted to just "minitab" (ignoring everything inside parenthesis). Is that expected behavior?
  2. Strangely, a page-title such as "Quality Function Deployment (QFD)" was converted to "qfd" (only taking the string inside parenthesis).
  3. I have a multilanguage setup. In this page-branch, only the default language pages are active. Some page-names were only converted for the default language, while others were converted in all three languages.

re: 1+2: Which one is expected behavior? 

Thanks for your help + clarifications.

Link to comment
Share on other sites

8 minutes ago, dragan said:

A page-title "Minitab (Statistik / Datenauswertung)" was converted to just "minitab" (ignoring everything inside parenthesis). Is that expected behavior?

Nope, I just tried and it was converted to: minitab-statistik-datenauswertung

Based on what you are seeing with BCE and PageRenameOptions, I feel like maybe you have some other code that is hooking into page name generation and messing with things.

Link to comment
Share on other sites

  • 1 month later...

Hi Adrian,

I need to import data to existing pages from CSV and am wondering if BCE might be a solution. I've read the GitHub readme and the module looks like a powerful beast but I'm not quite clear on a few things.

1. My data includes a Profields Textareas field, with the data for the individual subfields in separate columns. My guess is that this will require a custom import script (e.g. using AdminActions) but thought I'd check first to find out if BCE supports importing to fieldtypes that contain subfields.

2. I'm sure this is a silly question, but when BCE is enabled for a page or template in the config options this is for the parent of the pages that you want to batch edit, right? So when it comes to mapping columns to fields BCE is looking at the template of child pages under that parent? Does this mean the module can only work where there is a single allowed child template under the parent?

3. I have BCE set to Update mode but on my first attempt at importing a CSV I get an error message saying that the number of columns in the CSV doesn't match the number of fields in the template. Does this mean any CSV that is submitted for import must contain a column for every field and only columns for fields that exist in the template? There isn't a second step where you connect column headings to field names and can selectively import some columns while ignoring others?

4. The readme mentions CSV field pairings but I'm not sure where this is configured. I couldn't see anything about this in the module config.

5. Does BCE support a Page ID column in the CSV data, so there can be a rock-solid connection when importing data to existing pages? And if I use an ID column can I leave out page name and page title data from the CSV so I don't risk accidentally changing those?

Sorry for all the questions, and thanks for the module!

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