Jump to content

Batch Child Editor


adrian

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

  • 2 weeks later...

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.

Link to comment
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 ^-^

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

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

  • 1 month later...

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

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

  • 2 weeks later...

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

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

Link to comment
Share on other sites

  • 1 month later...

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

  • 6 months later...

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

  • 1 month later...

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

  • 4 weeks later...

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

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