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

    • No registered users viewing this page.
  • Similar Content

    • 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 creating a new measurement object from the sum or difference between two other objects. 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.
    • By tcnet
      File Manager for ProcessWire is a module to manager files and folders from the CMS backend. It supports creating, deleting, renaming, packing, unpacking, uploading, downloading and editing of files and folders. The integrated code editor ACE supports highlighting of all common programming languages.
      https://github.com/techcnet/ProcessFileManager

      Warning
      This module is probably the most powerful module. You might destroy your processwire installation if you don't exactly know what you doing. Be careful and use it at your own risk!
      ACE code editor
      This module uses ACE code editor available from: https://github.com/ajaxorg/ace

      Dragscroll
      This module uses the JavaScript dragscroll available from: http://github.com/asvd/dragscroll. Dragscroll adds the ability to drag the table horizontally with the mouse pointer.
      PHP File Manager
      This module uses a modified version of PHP File Manager available from: https://github.com/alexantr/filemanager
       
    • By tcnet
      This module implements the website live chat service from tawk.to. Actually the module doesn't have to do much. It just need to inserted a few lines of JavaScript just before the closing body tag </body> on each side. However, the module offers additional options to display the widget only on certain pages.
      Create an account
      Visit https://www.tawk.to and create an account. It's free! At some point you will reach a page where you can copy the required JavaScript-code.

      Open the module settings and paste the JavaScript-code into the field as shown below. Click "Submit" and that's all.

      Open the module settings
      The settings for this module are located int the menu Modules=>Configure=>LiveChatTawkTo.

       
    • By tcnet
      Session Viewer is a module for ProcessWire to list session files and display session data. This module is helpful to display the session data of a specific session or to kick out a logged in user by simply delete his session file. After installation the module is available in the Setup menu.

      The following conditions must be met for the module to work properly:
      Session files
      Session data must be stored in session files, which is the default way in ProcessWire. Sessions stored in the database are not supported by this module. The path to the directory where the session files are stored must be declared in the ProcessWire configuration which is by default: site/assets/sessions.
      Serialize handler
      In order to transform session data easier back to a PHP array, the session data is stored serialized. PHP offers a way to declare a custom serialize handler. This module supports only the default serialize handlers: php, php_binary and php_serialize. WDDX was dropped in PHP 7.4.0 and is therefore not supported by this module as well as any other custom serialize handler. Which serialize handler is actually used you can find out in the module configuration which is available under Modules=>Configure=>SessionViewer.

      Session data
      The session data can be displayed in two different ways. PHP's default output for arrays print_r() or by default for this module nice_r() offered on github: https://github.com/uuf6429/nice_r. There is a setting in the module configuration if someone prefers print_r(). Apart from the better handling and overview of the folded session data the output of nice_r() looks indeed nicer.

      Links
      ProcessWire module directory
      github.com
    • By Robin S
      Repeater Easy Sort
      Adds a compact "easy-sort" mode to Repeater and Repeater Matrix, making those fields easier to sort when there are a large number of items.
      The module also enhances Repeater Matrix by allowing a colour to be set for each matrix type. This colour is used in the item headers and in the "add new" links, to help visually distinguish different matrix types in the inputfield.
      Screencasts
      A Repeater field

      A Repeater Matrix field with custom header colours

      Easy-sort mode
      Each Repeater/Matrix item gets an double-arrow icon in the item header. Click this icon to enter easy-sort mode.
      While in easy-sort mode:
      The items will reduce in width so that more items can be shown on the screen at once. The minimum width is configurable in the field settings. Any items that were in an open state are collapsed, but when you exit easy-sort mode the previously open items will be reopened. You can drag an item left/right/up/down to sort it within the items. The item that you clicked the icon for is shown with a black background. This makes it easier to find the item you want to move in easy-sort mode. You can click an item header to open the item. An "Exit easy-sort mode" button appears at the bottom of the inputfield. Configuration
      In the field settings for Repeater and Repeater Matrix fields you can define a minimum width in pixels for items in easy-sort mode. While in easy-sort mode the items will be sized to neatly fill the available width on any screen size but will never be narrower than the width you set here.
      In the field settings for Repeater Matrix you can define a custom header colour for each matrix type using an HTML "color" type input. The default colour for this type of input is black, so when black is selected in the input it means that no custom colour will be applied to the header.
      Exclusions
      The easy-sort mode is only possible on Repeater/Matrix fields that do not use the "item depth" option.
       
      https://github.com/Toutouwai/RepeaterEasySort
      https://processwire.com/modules/repeater-easy-sort/
×
×
  • Create New...