adrian

Batch Child Editor

Recommended Posts

This module facilitates quick batch creation (titles only or CSV import for other fields), editing, sorting, deletion, and CSV export of all children under a given page. You can even provide an alternate parent page which allows for editing of an external page tree.
 
http://modules.processwire.com/modules/batch-child-editor/
https://github.com/adrianbj/BatchChildEditor
 
The interface can be added to the Children Tab, or in a new dedicated tab, or placed inline with other fields in the Content tab.
 
Various modes allow you to:

  • Lister - Embeds a customized Lister interface. Installation of ListerPro will allow inline ajax editing of displayed fields.
     
  • Edit - This allows you to rename existing child pages and add new child pages. It is non-destructive and so could be used on child pages that have their own children or other content fields (not just title). It includes the ability to quickly sort and delete pages and change page templates. Also allows full editing of each page via a modal dialog by clicking on the page name link.

    This is my preferred default setup - see how it replaces the default Children/Subpages with an easily addable/editable/sortable/renamable/deletable list. Note that the edit links open each child page in a modal for quick editing of all fields.

    post-985-0-98642800-1432782769_thumb.png
     
  • Add - adds newly entered page titles as child pages to the list of existing siblings. You could create a list of pages in Word or whatever and just paste them in here and viola!

    This screenshot shows the editor in its own tab (name is configurable) and shows some of the CSV creation options. Update and Replace modes look fairly similar but show existing page titles.

    post-985-0-16922200-1430761056_thumb.png
     
  • Update - Updates the titles (and any other fields if you enter CSV data) for the existing pages and adds any additionally entered pages.
     
  • Replace - Works similarly to Add, but replaces all the existing children. There are checks that prevent this method working if there are any child pages with their own children or other content fields that are not empty. This check can be disabled in the module config settings, but please be very careful with this.
     
  • Export to CSV - Generates a CSV file containing the fields for all child pages. Fields to be exported can to fixed or customizable by the user. Also includes an API export method.

    post-985-0-87901800-1432667874_thumb.png

Populating fields on new pages
 
In Add, Update, and Replace modes you can enter CSV formatted rows to populate all text/numeric fields, making for an extremely quick way of creating new pages and populating their content fields.
 
 
Predefined Field Pairings
 
Like the field connections setup from Ryan's CSV Importer, but defined ahead of time so the dev controls what columns from the CSV pair with which PW fields. This is especially powerful in Update mode giving editors the ability to periodically import a CSV file to update only certain fields on a entire set of child pages. These pairings also allow for importing fieldtypes with subfields - verified to work for Profields Textareas and MapMarker fields, but I think should work for most others as well - let me know if you find any that don't work.
 
 
Access permission
 
This module requires a new permission: "batch-child-editor". This permission is created automatically on install and is added to the superuser role, but it is up to the developer to add the permission to other roles as required.
 
Config Settings
 
This module is HIGHLY configurable down to setting up custom descriptions and notes for your editors. You define one config globally for the site and then optionally you can define completely custom configurations for each page tree parent on your site. There are too many settings to bother showing here - you really just need to look through all the options and play around with them!

  • Like 19

Share this post


Link to post
Share on other sites
Just released an improved version. Two main changes:

  1. You can now limit which types of editing the users have access to. You might want to disable the Create/Overwrite mode in some cases. Note that superusers have both modes regardless of this setting.
  2. You can now add new pages using the edit mode.
Docs and images in the first post have been updated

  • Like 3

Share this post


Link to post
Share on other sites

Life saver Adrian! I was just thinking that it would be nice to have feature two days ago for the project I am working on at the moment. I haven't tested it but from the looks of it very promising. Cheers

Share this post


Link to post
Share on other sites

Glad to hear it sounds useful - please let me know how it goes for you and if you have any suggestions for improvements. I haven't had much real world feedback yet, so I would appreciate hearing your experience.

Share this post


Link to post
Share on other sites

Adrian,

Thanks for this!

Just finished testing...two things:

Not sure if possible: Would it be possible, somehow to display names of child pages alongside their titles? This is helpful when 'overwrite names' is not checked; new pages are created with similar titles but different names. However, all the user sees are similar titles. Not a big issue since names are visible on hover of the titles of children pages above (i.e. the PW list of children/subpages).

I have been getting this error: You cannot bulk edit these child pages, because at least one page has a field which is not empty. Try the edit option, or delete existing child pages first.  in Create/Overwrite mode. Does this mean child pages fields have to be empty before they can be overwritten?

Thanks again for the module! Great to see that it respects the template family settings ^-^

Share this post


Link to post
Share on other sites

Hi kongondo,

Thanks for testing. I should be able to do something for you along the lines of displaying the page names - I'll take a look.

The error you are getting is an intentional protection when using the Create/Overwrite mode. Because this mode deletes all children and recreates them I check to make sure there are no other fields (other than title and name) that have content and also that there are no grandchildren that might be deleted. I guess I could add an additional config setting to allow this check to be turned off.

Alternatively, the Edit mode will work fine because it won't affect other fields or grandchildren.

I am thinking the config option would probably work well, but I am still worried that if this module is accidentally enabled on a template or page with lots of content fields, it could be very destructive without this check. Maybe it's just a case of the developer needing to be very aware of where they make it available.

Do you have any thoughts on the best approach here?

Share this post


Link to post
Share on other sites

Thanks for prompt response Adrian. Haven't thought much about best approach but for now I would err on the side of caution.

Alternative 1: Don't delete anything with other non-empty fields (other than name and title). However, the explanation you have on your post above should be included somewhere in the Warning. Maybe better....

Alternative 2: An extension of Alternative 1 (some Warning notice) + to skip only the problematic child pages, i.e. the operations should continue for child pages with empty fields but skipped over for those with content. Then, capture the titles of the problematic ones and display a separate single error message alongside the success message: "could not bulk/edit a, b, c, d, e, f, g, x, z, because...blah, blah" (up to a point, otherwise string can be very long!). This way, the user is not too disappointed. The current all or nothing can be frustrating if you've spent a while setting things up [but did not check for non-empty fields first]  :lol:. Unless I am missing something and Alternative 2 is the current behaviour?

Cheers

Edited by kongondo

Share this post


Link to post
Share on other sites

Cannot create child pages with cyrillic titles. Probably names are not generated through transliteration.

  • Like 1

Share this post


Link to post
Share on other sites

Ivan,

I am really not very experienced with non-latin characters, but I just changed page name sanitizer to include: "Sanitizer::translate" which I am hoping will do what you need. Otherwise I will need to revisit things and use the code from the core that dynamically generates the page names on the fly from the titles.

I have also added a few new features to this module:

  1. There is a new "Add" option so it is possible to bulk add new children regardless of the content and grandchildren of the other sibling pages.
  2. Also there is a new config setting for allowing you to override the content protection check when using the overwrite mode - obviously use with extreme caution.

Hope all those changes are useful.

First post updated with new options and screenshots.

Edited by adrian
  • Like 2

Share this post


Link to post
Share on other sites

Nope. Still doesn't work. Latin titles are ok. Cyrillic titles don't work. Pages just do not get created at all. If i put a list with some latin and some cyrillic titles, only pages with latin titles get created.

And a little inconsistensy, as I think. If you do not choose any of the edit modes in module preferencies, you get the module output in page setup with a blank dropdown. Maybe get some defaults or turn off the output if nothing is selected in edit modes options. But that is for when it's time to polish.

Share this post


Link to post
Share on other sites

Ok, I just committed another update and I just tested myself with some cyrillic characters and I think everything should be working fine now.

I also fixed the blank dropdown issue. Now if there are no edit modes set in the config, the editor is not available at all from the Children tab.

Please let me know how it goes for you.

  • Like 1

Share this post


Link to post
Share on other sites

Finally got to test it. It seems to work fine. It even adds a number to the end of the name, if a page with the same name already exists. Something that my regular PW 2.4 does not do. That makes me wonder if this module uses some standard PW method or a custom one. I quess there will be a number of similar cases with non-latin characters, so want to make this clear (but not smart enough for now to compare the code myself ).

Share this post


Link to post
Share on other sites

Glad it works for you now!

It even adds a number to the end of the name, if a page with the same name already exists. Something that my regular PW 2.4 does not do.

PW should be adding a number to the end of the name to avoid conflicts. When you say this doesn't work for you, is it with all names, or only with names with cyrillic characters in them?

That makes me wonder if this module uses some standard PW method or a custom one. 

BatchChildEditor uses a custom naming method if the Overwrite Names option is checked in the module config, but if adding or overwriting, it uses the built-in method. What happens if you use the Add option and create to child pages with the same title - does the number get appended to the second child's page name?

Share this post


Link to post
Share on other sites

Hi everyone,

Added some major new functionality to the edit mode today (see revised screenshot for 3. in the first post). Edit mode now includes quick addition, sorting, and deleting of pages as well as full editing via a modal popup editor, similar to the new PageTable interface, making use of MarkupAdminDataTable.

If you are using this, definitely worth updating, and if you're not using it, maybe it is now worth taking a look :)

Enable this on your home template and you have a powerful editing alternative with the added ability to automatically overwrite page names based on changed page titles, which I think is very handy during the development phase of a new site.

Please let me know if you find any bugs with this new version.

  • Like 3

Share this post


Link to post
Share on other sites

I just committed a small but significant change in behavior - now if you don't select any templates or pages in the config settings, the Batch Child Editor tools will be available for all pages in your site. 

I have found I want access to this a lot (mostly the rename, sort, and delete functionality of the EDIT mode) and it was annoying to have to go and enable it for the template or page before I could use it, so now it can easily be available to all pages on your site. Hope everyone else finds this more convenient also.

  • Like 5

Share this post


Link to post
Share on other sites

Another significant update which should be a huge timesaver.

You can now populate all the text/numeric fields on newly created child pages (Add & Overwrite modes) from CSV formatted rows.

This allows easy creation and population of all page content, for example you could populate an entire page tree of country details by pasting in CSV formatted content like:

"Bolivia, Plurinational State of",BO,"BOLIVIA, PLURINATIONAL STATE OF",BOL,68

"Bonaire, Saint Eustatius and Saba",BQ,"BONAIRE, SAINT EUSTATIUS AND SABA",BES,535

etc

etc

Hope you guys will find this as useful as I am :)

As always, let me know if you have any problems or suggestions for improvements!

  • Like 5

Share this post


Link to post
Share on other sites

Major feature enhancements currently available on dev branch  - https://github.com/adrianbj/BatchChildEditor/tree/dev

The new config settings rely on the new "OR" options for inputfield dependencies, so this new version requires the dev branch of PW.

Please test carefully and let me know if you have any problems or suggestions!
 
Thanks to ideas, testing and feedback from @mr-fan this module now supports the following new features which mostly focus on enhanced, customized CSV importing for page creation:

  • Custom configurations on a page by page basis (on the Settings tab) - you can set up a default config in the module settings, but override these for any parent page.
     
  • Ability to set up custom titles, descriptions, and notes so the interface can be tailored to the exact needs of your editors with page/template specific examples.
     
  • Option to have editing tools in a new tab, rather than in the Children Tab. Alternatively, you can now replace the current Children/Subpages list in the Children tab.
     
  • CSV upload and link to external URL, in addition to the existing textarea manual / paste entry.
     
  • Ability to predefine "field pairings". This means that editors can upload/link to CSV files that may contain more fields than you want to import, or there are fields in your template that are not included in the CSV. Think of it as a predefined version of the "Connect the Fields" functionality in Ryan's "Import Pages from CSV Files" module. This makes complex imports foolproof for non-tech site editors.

I think in most cases this could now replace the need for custom scripts for editor friendly, regular CSV importing.
 
Despite the added options, it should be just as simple to setup as before if you don't need any of the extra features.
 
Here are some screenshots to give you an idea.
 
Shows a very simple, restricted CSV upload setup with custom title, description, and notes fields. Note that it is in a custom labeled new tab, rather than under the Children tab.
 
post-985-0-05553000-1429545165_thumb.png
 
All the new parent page specific config settings. Note in particular the "Field Pairings" section where you define CSV column numbers to match PW field names.
 
post-985-0-63565900-1429545174_thumb.png
 
 
The only thing I am having some issues with is persistence of some error messages - if you have setup some options that conflict or otherwise cause a specific error to be sent, you may need to save the settings a couple of extra times to make the message go away - not sure if this is a PW bug or what at the moment, but it shouldn't affect functionality.

  • Like 6

Share this post


Link to post
Share on other sites

Another new option added to the dev branch!

The old "Overwrite" edit mode is now called "Replace" and there is a new Overwrite mode that updates the content of fields of existing pages.

An example use case would be to allow editors to periodically upload a CSV file to update certain fields in all child pages while leaving other fields intact. To make this happen you would utilize the Field Pairings option so their import would only edit the specified fields.

  • Like 4

Share this post


Link to post
Share on other sites

An example use case would be to allow editors to periodically upload CSV files to update certain fields in all child pages while leaving other fields intact. To make this happen you would utilize the Field Pairings option so their import would only edit the specified fields.

So I do have to give this a test after all. My current client is working with a master excel list, which is imported to pw and I've used Ryan's importer by now. But the ability to predefine the column to field connection is really nice and easy reimporting to update even more. Would it be possible to have different CSV "schemas"? Maybe later even in a per template notion.

Share this post


Link to post
Share on other sites

So I do have to give this a test after all. My current client is working with a master excel list, which is imported to pw and I've used Ryan's importer by now. But the ability to predefine the column to field connection is really nice and easy reimporting to update even more. Would it be possible to have different CSV "schemas"? Maybe later even in a per template notion.

Current behavior is that you can set general setting for different templates and set own settings on a per page basis.

This module is getting the absolute best solution to handle import CSV data to pages. Even it could be easy prepared to be used by clients without to much headache about posible damage...

I wanna thank you adrian - this evolution of the module is a really big one!

  • Like 1

Share this post


Link to post
Share on other sites

So I do have to give this a test after all. My current client is working with a master excel list, which is imported to pw and I've used Ryan's importer by now. But the ability to predefine the column to field connection is really nice and easy reimporting to update even more. Would it be possible to have different CSV "schemas"? Maybe later even in a per template notion.

@mr-fan has already mentioned this, but to clarify, the Field Pairings option is something that is configured on a page by page basis. You set these for the parent page and then all the children that are created from the import follow the defined rules. So I think this allows for the different CSV schemas you are talking about. I thought about doing it per template, but I actually thought that per page was more flexible and natural because afterall this modules is all about creating and the editing child pages of the current parent. I guess this might be a problem if your parent page's template allows for more than one child template. I don't think I have ever allowed this on any of my PW sites, but I am sure some of you do. This module allows the editor to choose the template for new child pages (if the template family settings allow multiple templates or there are no restrictions at all), so if the demand is there, I should be able to implement something along these lines, but please test the current setup first to see if it already suits your needs.

  • Like 1

Share this post


Link to post
Share on other sites

Thanks for the clarification. It just looked like a global configuration from the screenshots. Will install the module later today.

  • Like 1

Share this post


Link to post
Share on other sites

For those interested, I just committed another small update that includes a couple of fixes from @LostKobrakai as well as support for not needing to define the "title" field in the field pairings if you only have edit and overwrite mode enabled. This should make it much more flexible when running CSV data imports to update existing pages.

EDIT: Also just changed "Overwrite" edit mode to be called "Update" to better describe what it does and also to avoid confusion with the "Overwrite Names" option.

  • Like 4

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 Lex Sanchez
      Video or Social Post Embed
      Based on the TextformatterVideoEmbed module developed by Ryan Cramer, we have added the possibility to embed publications of the main social networks Facebook, Twitter and Instagram.
      ProcessWire Textformatter module that enables translation of YouTube, Vimeo, Instagram, Facebook, Twitter or Issuu URLs to full embed codes, resulting in a viewable video or social post in textarea fields you apply it to.
      How to install
      Download or Clone from Github: https://github.com/lexsanchez/VideoOrSocialPostEmbed
      Copy the VideoOrSocialPostEmbed.module file to your /site/modules/ directory (or place it in /site/modules/VideoOrSocialPostEmbed/).
      Click check for new modules in ProcessWire Admin Modules screen. Click install for the module labeled: "Video or Social Post Embed".
      Now you will be on the module config screen. Please make note of the config options and set as you see fit.
      How to use
      Edit your body field in Setup > Fields (or whatever field(s) you will be placing videos in). On the details tab, find the Text Formatters field and select "Video or Social Post Embed". Save.
      Edit a page using the field you edited and paste in YouTube, Vimeo, Facebook, Twitter, Instagram and/or Issuu URLs each on their own paragraph.
      Example
      How it might look in your editor (like TinyMCE):
      How it works
      This module uses YouTube, Vimeo, Instagram, Facebook, Twitter and Issuu oEmbed services to generate the embed codes populated in your content. After these services are queried the first time, the embed code is cached so that it doesn't need to be pulled again.
      Configuration
      You may want to update the max width and max height settings on the module's configuration screen. You should make these consistent with what is supported by your site design.
      If you change these max width / max height settings you may also want to check the box to clear cache, so that YouTube/Vimeo/Facebook/Twitter/Instagram/Issuu oembed services will generate new embed codes for you.
      Using with Markdown, Textile or other LML
      This text formatter is looking for a YouTube, Vimeo, Instagram, Facebook, Twitter or Issuu video URL surrounded by paragraph tags. As a result, if you are using Markdown or Textile (or something else like it) you want that text formatter to run before this one. That ensures that the expected paragraph tags will be present when VideoOrSocialPostEmbed runs. You can control the order that text formatters are run in by drag/drop sorting in the field editor.
      Copyright 2018 by Ryan Cramer / Updated by Lex Sanchez
    • By kixe
      Email Verification
      This module provides functions to validate email adresses and hosts. The module generates a textfile for blacklisted mailhosts (trashmail), which will be always up to date.
      Download
      https://modules.processwire.com/modules/email-verification/
      API
      // get module $mailcheck = $modules->get('EmailVerification'); // return bool/ string - automatted update of blacklist file $mailcheck->blacklisted(email|domain) // return bool - validate a top level domain, checks against IANA list $mailcheck->validTLD(tld) // return array of punycoded TLDs - cyclic updated, data pulled from IANA $mailcheck->getTLDs(cycle=2592000) // return bool - checks syntax converts to punycode $mailcheck->validDomainName(domain); // return bool - checks punycode encoded syntax $mailcheck->validHostName(host); // return bool - checks syntax and accessibility $mailcheck->validHost(email|domain) // add a single value to blacklist $mailcheck->addToBlacklist(email|domain) USAGE
      $mailcheck = $modules->get('EmailCheck'); $email = 'susi@trashmail.com'; if($mailcheck->blacklisted($email)) echo 'Email Provider not allowed'; if(!$mailcheck->validHost($email)) echo 'Mailhost not available'; Example blacklist file:  blacklist.txt
       
    • By teppo
      Code Blocks Textformatter is a tiny Textformatter module I cooked up to add support for code blocks to text/textarea/RTE fields on some of the sites I work with. Unlike a full-blown Markdown Textformatter – which is something that we already have in the core – this module simply adds support for fenced and inline code blocks.
      The syntax is based on the GitHub code block documentation, so please refer to that for additional instructions. The README at GitHub also includes some basic examples. As with any Textformatter, in order to enable this one, install it and enable it via field settings. Note that there's no syntax highlighting built in (at least for the time being), so use a tool of your choice for that – personally I prefer Prism.js.
      Since this module doesn't use a Markdown tool behind the scenes, but rather some home baked regular expressions, there's always the possibility that I've missed something – but please let me know if you use this module and run into any issues. On the other hand this module should be relatively fast and unobtrusive, as there are no unnecessary bits of code to run 
      GitHub repository: https://github.com/teppokoivula/TextformatterCodeBlocks Modules directory: http://modules.processwire.com/modules/textformatter-code-blocks/
    • By theo
      Here is my first processwire module (beta).
      https://github.com/theo222/ImagePickerField
      A lot of "first times". First time Github, Markdown and of course PW Modules.
      So be gentle please.
      I hope it works.