adrian

Batch Child Editor

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.

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Thanks again @sodesign - I have added that on that line, and also a few others.

Please test the latest version.

Share this post


Link to post
Share on other sites

@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

Share this post


Link to post
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.

 

Share this post


Link to post
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!

Share this post


Link to post
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

Share this post


Link to post
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... :-)

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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!

  • Like 1

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
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?

Share this post


Link to post
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! 😉

 

Share this post


Link to post
Share on other sites

I think it's probably because you haven't defined the parent as a page that is separately configurable. Do that and you should be fine:

image.thumb.png.8d742f308abad0ed0966ebe7881f175d.png

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
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 MoritzLost
      Hello there,
      I'm working on a tiny textformatter module that searches the text for titles of other pages on your site and creates hyperlinks to them. I'm not sure if something like this exists already, but I haven't found anything in the module directory, so I wrote my own solution 🙂
      It's not properly tested yet and is still missing some functionality I would like to implement, so at the moment it should be considered in BETA. Features include limiting the pages that will get searched by template, and adding a custom CSS class to the generated hyperlinks. As I'm writing this I noticed that it will probably include unpublished and hidden pages at the moment, so yeah ... it's still in development alright 😅
      You can download the module from Github:
      https://github.com/MoritzLost/TextformatterPageTitleLinks
      There's some more information in the readme as well.
      Anyway, let me know what you think! I'm happy about any feedback, possible improvements or ideas on how to improve the module. Cheers.
    • By adrian
      This module provides a way to rapidly generate Page fields and the required templates and pages for use as a drop down select (or any other Page field type).
      This module will let you create a full page field setup in literally a few seconds 
      To use, run Page Field Select Creator from the Setup Menu
      Enter a Field Title, eg: Room Types Select Options - These will become the child pages that will populate the page field select options. There are two different options.
       
      Option 1. TITLE FIELD ONLY - enter one option per line, eg:
       
      Single
      Double
      Suite
       
       
      Option 2. MULTIPLE FIELDS - the first line is used for the field names and the first field must be 'Title'. Subsequent lines are the values for the fields, eg:
       
      Title, Number of Beds, Number of People, Kitchen Facilities
      Single, 1, 1, Fridge Only
      Double, 2, 2, Fridge Only
      Suite, 3, 6, Full Kitchen
        Choose the parent where the page tree of options will be created, eg a hidden "Options" parent page Select a "Deference in API as" option depending on your needs Choose the input field type Check whether "Allow new pages to be created from field?" should be enabled. As an example, if you entered "Room Types" as the field title, you would end up with all of the following automatically created:
      a fully configured page field called: room_types MULTIPLE FIELDS OPTION - 3 additional fields - number_of_beds, number_of_people, kitchen a parent template called: room_types a child template called: room_types_items (with either just a title field, or with the 3 additional fields as well) a parent page called: Room Types a series of child pages named and titled based on the per line entries in the Select Options textarea The templates are configured such that the "room_types_items" child template can only have the main "room_types" template as a parent, and vice versa.

      Then all you have to do is add the newly created page field to any template you want and you're ready to go!
       
      You can grab it from:
       
      Modules directory: http://modules.processwire.com/modules/process-page-field-select-creator/
      Github: https://github.com/adrianbj/ProcessPageFieldSelectCreator
       

    • By bernhard
      WHY?
      This module was built to fill the gap between simple $pages->find() operations and complex SQL queries.
      The problem with $pages->find() is that it loads all pages into memory and that can be a problem when querying multiple thousands of pages. Even $pages->findMany() loads all pages into memory and therefore is a lot slower than regular SQL.
      The problem with SQL on the other hand is, that the queries are quite complex to build. All fields are separate tables, some repeatable fields use multiple rows for their content that belong to only one single page, you always need to check for the page status (which is not necessary on regular find() operations and therefore nobody is used to that).
      In short: It is far too much work to efficiently and easily get an array of data based on PW pages and fields and I need that a lot for my RockGrid module to build all kinds of tabular data.

      Basic Usage

       
      Docs & Download
      https://modules.processwire.com/modules/rock-finder/
      https://github.com/BernhardBaumrock/RockFinder
       
      Changelog
      180817, v1.0.6, support for joining multiple finders 180810, v1.0.5, basic support for options fields 180528, v1.0.4, add custom select statement option 180516, change sql query method, bump version to 1.0.0 180515, multilang bugfix 180513, beta release <180513, preview/discussion took place here: https://processwire.com/talk/topic/18983-rocksqlfinder-highly-efficient-and-flexible-sql-finder-module/
    • By BitPoet
      MediaLibrary
      Update: MediaLibrary can now be found in the official module list.
      Out of necessity, I've started to implement a simple media library module.
      The basic mechanism is that it adds a MediaLibrary template with file and image fields. Pages of this type can be added anywhere in the page tree.
      The link and image pickers in CKEditor are extended to allow quick selection of library pages from dropdowns. In the link picker this happens in the MediaLibrary tab, where you can also see a preview of the selected image. In the image picker, simply select a library from the dropdown at the top, everything else is handled by standard functionality.
      I've put the code onto github. This module is compatible with ProcessWire 3.
      Steps to usage:
      Download the module's zip from github (switch to the pw3 branche beforehand if you want to test on PW 3.x) and unpack it into site/modules Click "Modules" -> "Refresh" in the admin Click "Install" for MediaLibrary For testing, create a page with the MediaLibrary template under home (give it an expressive title like 'Global Media') and add some images and files Edit a differnt page with a CKEditor field and add a link and an image to see the MediaLibrary features in action (see the screencap for details) Optionally, go into the module settings for MediaLibrary Note: this module is far from being as elaborate as Kongondo's Media Manager (and doesn't plan to be). If you need a feature-rich solution for integrated media management, give it a look.
      Feel free to change the settings for MediaFiles and MediaImages fields, just keep the type as multiple.
      There are some not-so-pretty hacks for creating and inserting the correct markup, which could probably be changed to use standard input fields, though I'm a bit at a loss right now how to get it to work. I've also still got to take a look at error handling before I can call it fit for production. All feedback and pointers are appreciated (that's also why I post this in the development section).

      Edit 09.03.2016 / version 0.0.4: there's now also a "Media" admin page with a shortcut to quickly add a new library.

      Edit 01.05.2016:
      Version 0.0.8:
      - The module now supports nested media libraries (all descendants of eligible media libraries are also selectable in link/image picker).
      - There's a MediaLibrary::getPageMediaLibraries method you can hook after to modify the array of available libraries.
      - You can switch between (default) select dropdowns or radio boxes in the module configuration of MediaLIbrary to choose libraries.
      Edit 10.10.2018:
      Version 0.1.3:
      - Dropped compatibility for ProcessWire legacy versions by adding namespaces
      - Allow deletion of libraries from the Media overview admin page
      - Added an option to hide media libraries from the page tree (optionally also for superusers)
    • By Robin S
      This module corrects a few things that I find awkward about the "Add New Template" workflow in the PW admin. I opened a wishlist topic a while back because it would good to resolve some of these things in the core, but this module is a stopgap for now.
      Originally I was going to share these as a few standalone hooks, but decided to bundle them together in a configurable module instead.
      Add Template Enhancements
      A module for ProcessWire CMS/CMF. Adds some efficiency enhancements when adding or cloning templates via admin.

      Features
      Derive label from name when new template added: if you like to give each of your templates a label then this feature can save some time. The label can be added automatically when templates are added in admin, in admin/API, or not at all. There are options for underscore/hyphen replacement and capitalisation of the label. Edit template after add: when adding only a single template, the template is automatically opened for editing after it is added. Copy field contexts when cloning: this copies the field contexts (a.k.a. overrides such as column width, label and description) from the source template to the new template when using the "Duplicate/clone this template?" feature on the Advanced tab. Copy field contexts when duplicating fields: this copies the field contexts if you select the "Duplicate fields used by another template" option when adding a new template. Usage
      Install the Add Template Enhancements module.
      Configure the module settings according to what suits you.
       
      https://github.com/Toutouwai/AddTemplateEnhancements
      https://modules.processwire.com/modules/add-template-enhancements/