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

2 minutes ago, dragan said:

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

Hope you like it - I can't imagine using PW without it 🙂 , especially during the development phase.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Similar Content

    • By monollonom
      PageMjmlToHtml
      Github: https://github.com/romaincazier/PageMjmlToHtml
      Modules directory: https://processwire.com/modules/page-mjml-to-html/ (pending approval)
      A module allowing you to write your Processwire template using MJML and get a converted HTML output using MJML API.
      This is considered to be in alpha and as such needs some testing before being used in production!

      About
      Created by Mailjet, MJML is a markup language making it a breeze to create newsletters displayed consistently across all email clients.
      Write your template using MJML combined with Processwire’s API and this module will automatically convert your code into a working newsletter thanks to their free-to-use Rest API.
      Prerequisite
      For this module to work you will need to get an API key and paste it in the module’s configuration.
      Usage
      Once your credentials are validated, select the template(s) in which you’re using the MJML syntax, save and go visualize your page(s) to see if everything’s good. You will either get error/warning messages or your email properly formatted and ready-to-go.
      From there you can copy/paste the raw generated code in an external mailing service or distribute your newsletter using ProMailer.
      Features
      The MJML output is cached to avoid repetitive API calls Not cached if there are errors/warnings Cleared if the page is saved Cleared if the template file has been modified A simple (dumb?) code viewer highlights lines with errors/warnings A button is added to quickly copy the raw code of the generated newsletter Not added if the page is rendered outside of a PageView Only visible to users with the page’s edit permission A shortcut is also added under “View” in the edit page to open the raw code in a new tab Multi-languages support
      Notes
      The code viewer is only shown to superusers. If there’s an error the page will display:
      Only its title for guests Its title and a message inviting to contact the administrator for editors If you are using the markup regions output strategy, it might be best to not append files to preserve your MJML markup before calling the MJML API. This option is available in the module’s settings.
    • By Marco Ro
      Hi guys!
      I'm a bit anxious because this is the first module I present! (beta modulo) But I will finally be able to share something with the community too! :)
      This is a BETA version of the PayPal payment system called: PayPal Commerce Platform.
      It is an advanced system (Business Pro account is needed) that brings various benefits in terms of fees and above all integrates direct payment with credit/debit cards. 
      The module integrates with Padloper 0.0.2, which is the current installation I'm using.
      This system integrates the classic PayPal buy button, the alternative or local payment method and the new payment system: credit/debit cards that doesn't go through the PayPal account. It is a Stripe-style payment, it connects directly with the bank and integrates 3D security validation.
      I say that it is a BETA because this module currently only works with Sandbox account, to put it live you need to change API url manually (manually for the moment).
      Because this module is not ready for live:
      I would like to have your opinion on how I built the module (is the first one I do). I don't want to share something that is not fish but I need a comparison with someone more experienced than me, for be sure that this is the best way to code the module.
      If you want to try this I created a git, you will find all the instructions for installation and correct operation. (Git has a MIT licensed)
      https://github.com/MarcooRo/processwire-PayPal-Commerce-Platform I hope I did something that you guys can like :)
    • By monollonom
      (once again I was surprised to see a work of mine pop up in the newsletter, this time without even listing the module on PW modules website 😅. Thx @teppo !)
      FieldtypeQRCode
      Github: https://github.com/romaincazier/FieldtypeQRCode
      Modules directory: https://processwire.com/modules/fieldtype-qrcode/
      A simple fieldtype generating a QR Code from the public URL of the page, and more.
      Using the PHP library QR Code Generator by Kazuhiko Arase.

      Options
      In the field’s Details tab you can change between .gif or .svg formats. If you select .svg you will have the option to directly output the markup instead of a base64 image. SVG is the default.
      You can also change what is used to generate the QR code and even have several sources. The accepted sources (separated by a comma) are: httpUrl, editUrl, or the name of any text/URL/file/image field.
      If LanguageSupport is installed the compatible sources (httpUrl, text field, ...) will return as many QR codes as there are languages. Note however that when outputting on the front-end, only the languages visible to the user will be generated.
      Formatting
      Unformatted value
      When using $page->getUnformatted("qrcode_field") it returns an array with the following structure:
      [ [ "label" => string, // label used in the admin "qr" => string, // the qrcode image "source" => string, // the source, as defined in the configuration "text" => string // and the text used to generate the qrcode ], ... ] Formatted value
      The formatted value is an <img>/<svg> (or several right next to each other). There is no other markup.
      Should you need the same markup as in the admin you could use:
      $field = $fields->get("qrcode_field"); $field->type->markupValue($page, $field, $page->getUnformatted("qrcode_field")); But it’s a bit cumbersome, plus you need to import the FieldtypeQRCode's css/js. Best is to make your own markup using the unformatted value.
      Static QR code generator
      You can call FieldtypeQRCode::generateQRCode to generate any QR code you want. Its arguments are:
      string $text bool $svg Generate the QR code as svg instead of gif ? (default=true) bool $markup If svg, output its markup instead of a base64 ? (default=false) Hooks
      Please have a look at the source code for more details about the hookable functions.
      Examples
      $wire->addHookAfter("FieldtypeQRCode::getQRText", function($event) { $page = $event->arguments("page"); $event->return = $page->title; // or could be: $event->return = "Your custom text"; }) $wire->addHookAfter("FieldtypeQRCode::generateQRCodes", function($event) { $qrcodes = $event->return; // keep everything except the QR codes generated from editUrl foreach($qrcodes as $key => &$qrcode) { if($qrcode["source"] === "editUrl") { unset($qrcodes[$key]); } } unset($qrcode); $event->return = $qrcodes; })
    • By Sebi
      AppApiFile adds the /file endpoint to the AppApi routes definition. Makes it possible to query files via the api. 
      This module relies on the base module AppApi, which must be installed before AppApiFile can do its work.
      Features
      You can access all files that are uploaded at any ProcessWire page. Call api/file/route/in/pagetree?file=test.jpg to access a page via its route in the page tree. Alternatively you can call api/file/4242?file=test.jpg (e.g.,) to access a page by its id. The module will make sure that the page is accessible by the active user.
      The GET-param "file" defines the basename of the file which you want to get.
      The following GET-params (optional) can be used to manipulate an image:
      width height maxwidth maxheight cropX cropY Use GET-Param format=base64 to receive the file in base64 format.
    • By MarkE
      This fieldtype and inputfield bundle was built for storing measurement values within a field, rendering them in a variety of formats and converting them to other units or otherwise modifying them via the API.
      The API consists of a number of predefined functions, some of which include...
      render() for rendering the measurement object, valueAs() for converting the value to another unit value, convertTo() for converting the whole measurement object to different units, and add() and subtract() for for modifying the stored value by the value (converted as required) in another measurement. In the admin the inputfield includes a checkbox (which can be optionally disabled) for converting values on page save. For an example if a value was typed in as centimeters, the unit was changed to metres, and the page saved with this checkbox selected, said value would be automatically converted so that e.g. 170 cm becomes 1.7 m.

      A simple length field using Fieldtype Measurement and Inputfield Measurement.
      Combination units (e.g. feet and inches) are also supported.
      Please note that this module is 'proof of concept' at the moment - there are limited units available and quite a lot of code tidying to do. More units will be added shortly.
      See the GitHub at https://github.com/MetaTunes/FieldtypeMeasurement for full details and updates.
×
×
  • Create New...