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

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 Macrura
      Field Descriptions Extended
      This module enables you to extend field descriptions by dividing short descriptions with a longer text that is revealed in a toggle.
      Modules Directory: http://modules.processwire.com/modules/field-descriptions-extended/
      Github: https://github.com/outflux3/FieldDescriptionsExtended
      Extending your field descriptions using the standard field's description field.
      Once this module is installed, it will automatically search your description field for the presence of 5 dashes (-----).
      Any content above the 5 dashes will be visible and the content below the dashes will be hidden. A 'More...' link will appear at the end of the short description which when clicked will reveal the rest of the description.
      Using Simple Markdown Editor with the description field
      If you have Simple Markdown Editor (InputfieldSimpleMDE) installed, you can enable the field description to have that editor.
      *When using Simple MDE, you can use the button (Insert Horizontal Line) instead of typing 5 dashes. More about SimpleMDE.
      Extending your field descriptions using content from a ProcessWire Page for the field description.
      You may use the content from a ProcessWire page as a field description. This would allow you to easily insert images, links, and use hanna codes.
      To use page content for your field descriptions, please follow these instructions:
      Install Select Fields module (FieldtypeFields) http://modules.processwire.com/modules/fieldtype-fields/ Create a new field using this field type, e.g. field_select. Add the field to any template you will be using for your field descriptions. Setup your help pages (for example under a settings branch) where you will store the field description content,using the template containing the Field Select. Add content to a page and select the field where that content should show. To show a short text before the link to the longer content, separate them with 5 dashes Be sure to update your settings on this page, first enable page content descriptions,then specify the name of the Select Fields field, template to search, and content field. If you create a field description using this method, please note that the description field must be blank for contexts where you want the page content to appear.
      You can freely use template context for field descriptions, but the Page Content method is not context sensitive and will display under all contexts where the description is blank.
      ----
      original post:
      This is a new module, hope to release soon, which allows extended field descriptions, in currently 2 ways.
      The main feature of the module is that you can have a short description and then a 'more...' link which drops down a longer block of text.
      This is achieved by separating the intro/visible text and the rest with 5 dashes.

      Example setup:

      the 2nd way is if you are using AdminThemeUiKit, you can show extended field instructions in a panel. The content of the panel is edited on a regular PW page. This use case would probably not be that common, but if you had a field that required some extended instructions for how to use, this could be useful; Also, since this allows you to target information and instructions down at the field level, it could reduce the amount of documentation needed on a global level, since it is a lot more context targeted.

    • By Robin S
      Breadcrumb Dropdowns
      Adds dropdown menus of page edit links to the breadcrumbs in Page Edit.

      Installation
      Install the Breadcrumb Dropdowns module. The module requires ProcessWire >= v3.0.83 and AdminThemeUikit.
      There is a checkbox option in the module config that determines if the breadcrumb dropdowns will include pages that the user does not have permission to edit.
      Features/details
      The module adds an additional breadcrumb item at the end for the currently edited page. That's because I think it's more intuitive for the dropdown under each breadcrumb item to show the item's sibling pages rather than the item's child pages. In the dropdown menus the current page and the current page's parents are highlighted in a crimson colour to make it easier to quickly locate them in case you want to edit the next or previous sibling page. If the option to include uneditable pages is selected then those pages are indicated by a reduced text opacity and the "not-allowed" cursor is shown on hover. There is a limit of 25 sibling pages per dropdown for performance reasons and to avoid the dropdown becoming unwieldy. Incompatibilities
      This module replaces the AdminThemeUikit::renderBreadcrumbs method so will potentially be incompatible with other modules that hook the same method.
       
      https://modules.processwire.com/modules/breadcrumb-dropdowns/
      https://github.com/Toutouwai/BreadcrumbDropdowns
    • By joshuag
      Hey guys, 
      Thought I would share a quick preview of Designme. A module we (Eduardo @elabx and I) are building for visually laying out your templates/edit screens. 🙂
      This is a really quick, zero polish screen grab. FYI. 
      Video #2 - UPDATE
      This new video shows the following features in Designme:
      Re-arranging fields via Drag & Drop Re-sizing fields via Dragging. Adjusting field settings - with live refresh. Working on "hidden" fields while Designme is active. Creating New fields. Deleting fields. Creating/Deleting Tabs. Dragging fields between tabs. Creating fieldsets. Tagging/Un-tagging fields. Fields without headers expand when hovered (like checkboxes). Live filtering of fields in the sidebar. Ability to adjust (all) Template settings without leaving Designme. Template File Tree Editing Template files source code with ACE Editor. Editing Multiple files with ACE Editor. (New Tabs) Saving files. Techie stuff Fields load their own js/css dependancies. *ready to use on creation (*most fields)  Everything happens via Ajax to ProcessPageEdit (via module + hooks). Designme has a JS api that you can use.  All actions trigger events.  We would love any detailed feedback on what you see so far. If you are interested in testing Designme. Let me know below. 🙂
       
       
      Video #1. 
       
    • By dreerr
      TemplateEnginePug (formally TemplateEngineJade)
       
      This module adds Pug templates to the TemplateEngineFactory. It uses https://github.com/pug-php/pug to render templates.
      doctype html html(lang='en') head meta(http-equiv='content-type', content='text/html; charset=utf-8') title= $page->title link(rel='stylesheet', type='text/css', href=$config->urls->templates . 'styles/main.css') body include header.pug h1= $page->title if $page->editable() p: a(href=$page->editURL) Edit Project on GitHub: github.com/dreerr/TemplateEnginePug
      Project in modules directory: modules.processwire.com/modules/template-engine-pug/
       
      For common problems/features/questions about the Factory, use the TemplateEngineFactory thread.
       
    • By tpr
      ProcessNetteTester
      Run Nette Tester tests within ProcessWire admin.
      (continued from here)

      Features
      AJAX interface for running Nette Tester tests, in bulk or manually display counter, error message and execution time in a table run all tests at once or launch single tests show formatted test error messages and report PHP syntax errors stop on first failed test (optional) hide passed tests (optional) display failed/total instead passed/total (optional) re-run failed tests only (optional) auto scroll (optional) include or exclude tests based on query parameters start/stop all tests with the spacebar reset one test or all tests (ctrl+click) https://modules.processwire.com/modules/process-nette-tester/
      https://github.com/rolandtoth/ProcessNetteTester