Jump to content

Batch Child Editor


adrian

Recommended Posts

Thanks @sodesign - looks like you are using a Page Reference field that only accepts a single value, under Details >  Page field value type - is that correct?

I think I must not have properly tested with Single. Can you please try replacing:

            if(!$pageMatch->id && $title!='') {

with:

            if(!$pageMatch->id && $childFieldValue!='') {

here:

https://github.com/adrianbj/BatchChildEditor/blob/f3a77b5338fd69b14b939edbae9948f42af2fc14/BatchChildEditor.module#L1675

Please let me know if that works.

Link to comment
Share on other sites

4 minutes ago, sodesign said:

Perfect, that's now working without error.

Thank you for resolving this!

No worries - thanks for reporting and helping to debug.

I have committed a new version with this fix.

  • Like 1
Link to comment
Share on other sites

Just a quick follow-up to this - I have been importing more content in a tsv and ran across another issue.

When the title of the page being matched contains a comma, the selector in the line above throws an error.

$pageMatch = $this->wire('pages')->get("id=$options, title={$childFieldValue}");

An example page title is "Fixed Height, Loop Leg" - The error was from the Selector class, and the snippet included something to the effect of: "field: Fixed, value: Height "

I think this was why I had used the selector value sanitizer method previously.

I tried this:

$pageMatch = $this->wire('pages')->get("id=$options, title={$this('sanitizer')->selectorValue($childFieldValue)}");

The import runs successfully, though I'm unsure if this might have knock-on effects elsewhere.

 

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

@adrian

Got this error after install and trying to edit a page.

Error: Uncaught Error: Call to a member function getLanguageValue() on null in .../site/modules/BatchChildEditor/BatchChildEditor.module:860

The error occurs due to the fact there is no title field assigned to the page template. I think your module should handle this since its easy to remove title now with the $template->noGlobal option.


.. and this one in the exported csv file after using the template you provided in the README.md

<br />
<b>Notice</b>:  Undefined index: configurablePages in <b>.../site/assets/cache/FileCompiler/site/modules/BatchChildEditor/ProcessChildrenCsvExport.module</b> on line <b>94</b><br />
<br />
<b>Warning</b>:  in_array() expects parameter 2 to be array, null given in <b>.../site/assets/cache/FileCompiler/site/modules/BatchChildEditor/ProcessChildrenCsvExport.module</b> on line <b>94</b><br />
<br />

 

Edited by kixe
2nd error
Link to comment
Share on other sites

First is fixed. Thanks. :rolleyes:
While playing around getting still some notices:

Notice:  Trying to get property of non-object in .../site/assets/cache/FileCompiler/site/modules/BatchChildEditor/ProcessChildrenCsvExport.module on line 230

https://github.com/adrianbj/BatchChildEditor/blob/2e079d342ea56ac7be58ae2de4d6cdc1317eec0e/ProcessChildrenCsvExport.module#L230

check wire('fields')->$fieldName first

Notice:  Trying to get property of non-object in .../site/assets/cache/FileCompiler/site/modules/BatchChildEditor/ProcessChildrenCsvExport.module on line 161

https://github.com/adrianbj/BatchChildEditor/blob/master/ProcessChildrenCsvExport.module#L161

field label expected but field label is not required. Needs fallback to name.

 

Link to comment
Share on other sites

Sorry about the other notices - I have never dealt with templates without a title field before.

Any chance you feel like putting together a PR for these as you find them? Sorry, I am not going to have much time for my PW modules for a while.

Thanks!

Link to comment
Share on other sites

I ended up with the following simple template since I was just looking for a csv export/ download option. It works without any errors for any kind of field (repeaters included)

<?php
// template provides file download of some children data in csv format
// export as CSV if $_GET['csv_export‘] == 1 is in url
if(isset($input->get->csv_export) && $input->get->csv_export == 1) {
    // create data array
    $data = $page->children->explode(function($item){
        return array(
            'ID'=> $item->id, // page property
            'Author' => $item->author->first()->name, // page field
            'Length' => $item->timeslots? $item->timeslots * 30 : 0, // integer field
            'Info' => $item->info // runtime markup field
        );
    });
    // set header
    header("Content-type: text/csv");
    header("Content-Disposition: attachment; filename=file.csv");
    header("Pragma: no-cache");
    header("Expires: 0");
    $output = fopen("php://output", "wb");
    foreach ($data as $fields) fputcsv($output, $fields);
    fclose($output);
    exit;
}
// display content of template with link to same page with appended csv_export=1
else {
   $page->_content = "<a href='./?csv_export=1'>Export Child Pages as CSV</a>"; //link to initiate export
}

 

  • Like 1
Link to comment
Share on other sites

19 hours ago, kixe said:

I ended up with the following simple template since I was just looking for a csv export/ download option. It works without any errors for any kind of field (repeaters included)


<?php
// template provides file download of some children data in csv format
// export as CSV if $_GET['csv_export‘] == 1 is in url
if(isset($input->get->csv_export) && $input->get->csv_export == 1) {
    // create data array
    $data = $page->children->explode(function($item){
        return array(
            'ID'=> $item->id, // page property
            'Author' => $item->author->first()->name, // page field
            'Length' => $item->timeslots? $item->timeslots * 30 : 0, // integer field
            'Info' => $item->info // runtime markup field
        );
    });
    // set header
    header("Content-type: text/csv");
    header("Content-Disposition: attachment; filename=file.csv");
    header("Pragma: no-cache");
    header("Expires: 0");
    $output = fopen("php://output", "wb");
    foreach ($data as $fields) fputcsv($output, $fields);
    fclose($output);
    exit;
}
// display content of template with link to same page with appended csv_export=1
else {
   $page->_content = "<a href='./?csv_export=1'>Export Child Pages as CSV</a>"; //link to initiate export
}

 

Will be willing to test anytime!! I have tons of pages with repeaters to export in CSV... :-)

Link to comment
Share on other sites

  • 1 month later...

I found a definite bug (latest module+pw 3.0.96)

If you go to a page and click children, choose batch edit, choose "edit" mode (only one i tested) as the option and then in the list; edit some children in the modal and save those - the children titles in the parent will have no value set for "title" and in the batch list it now shows empty values where the titles used to be.

It appears that the variable for title is not saving or updating properly. I was editing other fields but for some reason it made my titles blank when I didn't edit the titles... very odd.

Screenshot-2018-3-21 Edit Page Streams • 127 0 0 1.png

also the title in the actual children themselves is now empty (in English, French is fine)

  • Like 1
Link to comment
Share on other sites

9 minutes ago, adrian said:

Hi @neosin - thanks for reporting - looks like it was a multi-language site bug that crept in at some point.

Can you please try the latest version and let me know if everything looks ok now?

Thanks!

updated and I can confirm the issue is resolved thanks.

On a side note, I keep getting mixed up with the save buttons all over the place in the modal and the pages. Clicking save twice will take some getting used to.

 

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

Hi @adrian, I have found an issue regarding page reference field.

If the template does not contain title field and the page reference field is listed at the top, i.e. first template field, the module would fail to add/replace the correct value and show empty for that page reference field, while other position is working fine.

Link to comment
Share on other sites

  • 4 weeks later...
On 8/29/2017 at 12:49 PM, adrian said:

 

I decided to go ahead to do this so now you can specify exactly which pages will be exported. Hopefully others will find this useful also:

59a59afd39c8a_ScreenShot2017-08-29at9_48_25AM.thumb.png.9894f14c4bb7947dc309967682ac8e37.png

 

Hi,

Does this works in 1.8.10 (PW 3.0.106)? I don't see this selector.

Thanks!

 

image.png.a1504cc0b4333e50f1ad2d4373a613fa.png

Link to comment
Share on other sites

1 hour ago, mel47 said:

Does this works in 1.8.10 (PW 3.0.106)? I don't see this selector.

Yep, it works, but if you want it to appear at the time of export then you need to check "User override CSV settings" - otherwise it will use the selector defined on the page's settings tab. Does that make sense?

Link to comment
Share on other sites

18 hours ago, adrian said:

Yep, it works, but if you want it to appear at the time of export then you need to check "User override CSV settings" - otherwise it will use the selector defined on the page's settings tab. Does that make sense?

Hum, I really feel stupid. It's not there either.

image.thumb.png.5df053b394803f8a6a6e914befb66e6d.png

 

But to answer your question, nope for me it does make sense. Sorry... 😉 The description mentions only separator and stuff like this, nothing about page selector. I would never have activated this option since I don't really need/want to modify those options. But I guess if it works, I will be fine with that! 😉

 

Link to comment
Share on other sites

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!

 

 

  • Like 1
Link to comment
Share on other sites

22 hours ago, mel47 said:

however the page selector/fields to export are still sticking to my export CSV in BCE tab.

Thanks for noticing that - good catch. It should be fixed in the latest version.

Sorry you're not finding it user-friendly - I agree it's become quite the behemoth in terms of config settings - it makes it very flexible it terms of the interface you can craft for your site editors, but I understand it can be a little unwieldy to configure.

Link to comment
Share on other sites

53 minutes ago, adrian said:

Thanks for noticing that - good catch. It should be fixed in the latest version.

Sorry you're not finding it user-friendly - I agree it's become quite the behemoth in terms of config settings - it makes it very flexible it terms of the interface you can craft for your site editors, but I understand it can be a little unwieldy to configure.

The problem, IMHO, is the absence of mention in description of config. If it's written somewhere than these settings while appear in tab settings of a configurable page, I will not have search that much for it.  But I don't blame, I have myself problems to well documenting my own code... 😉

At least someone else can now find the information if they search the thread.

Link to comment
Share on other sites

  • 1 month later...

Installed this module and didn't get it to work at first, now I'm stuck with an error "Error: Using $this when not in object context (line 907 of /var/www/clubmoral_com/site/modules/BatchChildEditor/BatchChildEditor.module) " when I go to the parent page from which I want to export children as csv.

PW 3.0.98 Module version 1.8.12

Link to comment
Share on other sites

4 hours ago, BFD Calendar said:

Installed this module and didn't get it to work at first, now I'm stuck with an error "Error: Using $this when not in object context (line 907 of /var/www/clubmoral_com/site/modules/BatchChildEditor/BatchChildEditor.module) " when I go to the parent page from which I want to export children as csv.

PW 3.0.98 Module version 1.8.12

I think the issue is likely php 5.3 - is that the version you are using?

Any chance you can upgrade?

If not, let me know and I can make an adjustment to support 5.3

Link to comment
Share on other sites

Yes, it's PHP 5.4. It's a free fast unlimited hosting but they don't want to upgrade.

In the meantime I used Ryan's new import/export module and already finished very well what I wanted to do (copy pages from one site to another). I don't think I'll need it on this site, but thanks anyway.

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