Coder Social home page Coder Social logo

adrianbj / batchchildeditor Goto Github PK

View Code? Open in Web Editor NEW
13.0 3.0 3.0 515 KB

Processwire modules for quick batch creation, editing, sorting, and deletion of all children under a given page.

License: GNU General Public License v2.0

JavaScript 6.02% PHP 93.04% CSS 0.83% Makefile 0.11%
processwire csv-export csv-import batch editing

batchchildeditor's Introduction

BatchChildEditor

Processwire module for quick batch creation (titles only or CSV import for other fields), editing, sorting, deletion, and CSV export of all children under a given page.

This module adds a variety of importing, editing, and exporting tools. 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.

Modes

  1. Lister - Embeds a customized Lister interface. Installation of ListerPro will allow inline ajax editing of displayed fields.
  2. Edit - Allows you to quidkly rename existing child pages, add new child pages, sort, and delete pages. It also has a modal edit link from the page name to allow easy access to edit all the fields on the page.
  3. 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!
  4. Update - This allows updating of existing pages - the title, name and all other fields.
  5. Replace - This completely replaces all existing child pages with new pages. 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.
  6. Export to CSV - Generates a CSV file containing the fields for all child pages. Fields to be exported can be fixed or customized by the user. Also includes an API export method.

In Add, Update, and Replace modes you can enter CSV formatted rows to populate all text/numeric fields. This can be used to create new pages or to update existing pages. CSV field pairings can be defined to make it easy for editors to periodically create new pages, or update the fields in existing pages.

There is also an exportCsv() API method that can be used like this:

<?php
// export as CSV if csv_export=1 is in url
if($input->get->csv_export==1){
   $modules->get('ProcessChildrenCsvExport'); // load module
   // delimiter, enclosure, file extension, names in first row, multiple field separator, format values, pages to include (selector string), array of field names
   $page->exportCsv(',', '"', 'csv', true, "\r", true, 'include=all', array('title','body','images','textareas'));
   //$page->exportCsv() - this version uses the defaults from the module or page specific settings
}
// display content of template with link to same page with appended csv_export=1
else{
   include("./head.inc");

   echo "<a href='./?csv_export=1'>Export Child Pages as CSV</a>"; //link to initiate export

   include("./foot.inc");
}

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

There are module-wide config settings, but these can be overwritten with page specific permissions which allows for highly customized creation and editing tools.

  • Which pages and templates will have the editor available and which can be separately configured.
  • Which edit modes should be availble to the user.
  • Alternate parent page - allows editing of external page tree.
  • Which data entry options (Text, Upload, URL link) should be availble to the user.
  • CSV import options.
  • CSV field pairings - really powerful for creating and updating pages - read more about it in the config settings.
  • CSV export options.
  • Whether the name of the page should also be changed along with the title. This is a very important setting and should be considered carefully, especially is the child pages are URL accessible.
  • Whether users can decide whether the name is also changed or not.
  • Whether to disable content protection for existing child pages and their children.
  • Trash or Delete.
  • Load Batch interface Open or Collapsed (open for quicker access).
  • Position interface (top, bottom, replace, new tab, inline fieldset).
  • Custom Title, Description, and Notes for each mode - allows you to tailor the editing interface specifically to your content editors and to specific content.

Support forum:

https://processwire.com/talk/topic/6102-batch-child-editor/

License

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

(See included LICENSE file for full license text.)

batchchildeditor's People

Contributors

adrianbj avatar mestaritonttu avatar mr-fan avatar rolandtoth avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

batchchildeditor's Issues

Lister mode doesn't work

I've installed Lister Pro module, my goal is to batch edit listed pages.
However Auto Page Rename module doesn't play nicely with Lister Pro, so I decided to try BatchChildEditor in Lister mode..
I read here that if I have Lister Pro, I'm able to edit inline the pages in this mode. https://devhub.io/repos/adrianbj-BatchChildEditor
I can't, I get this error:

image

Feature Request: Resolve internal values on CSV-Export

Hi, first. thanks for that nice module!

I have a feature request for the CSV-Export: At the moment, only internal values are exported. This makes sense for usecases, where they are to be imported back to a PW-instance with the same template. But for other usecases, it doesn't. We have a place database and want to export the places to be used within other software. But the export only uses the internal values of ProcessWire like the ID of the select option for a select field instead of its readable representation. So I have to give along a detailed legend for what all those integers stand for and someone has to normalize the data within the CSV before it can be processed. And that legend approach doesn't work at all for related pages, where I need the page's title field to be exported instead its id.

So what I basically want is that I can choose if I want to export the human readable values of the fields or their internal numeric value:

"Place category";Title;"Furnishing type"
2;"03.2.003 Classroom";2
1;"03.2.004 Auditorium";1

"Place category";Title;"Furnishing type"
"Classroom";"03.2.003 Classroom";"desks and chairs"
"Auditorium";"03.2.004 Auditorium";"fixed seats"

I had expected the "Turns on output formatting for exported values." setting to switch between the variants, but in my case both export the same.

Notice: Trying to get property of non-object

Notice: Trying to get property of non-object in /…/modules/BatchChildEditor.module on line 860

I'm getting this error when editing pages that have children without title field. Should by simple to fix with some conditioning. So title should not be expected as default on every page because it can be removed from templates.

Edit Tab: Critical Bug — title values are not escaped!

$cp->title needs to be escaped with htmlspecialchars($cp->title)

BatchChildEditor.module, line 757:

<input id="'.$cp->id.'" type="text" name="individualChildTitles['.$cp->id.']" value="'.$cp->title.'" style="width:100%" '. (!$cp->editable() ? " readonly" : "") . ' />

— this messed up some of my pages that has quotes in the title!

jQuery.fn.size() is deprecated

Hi, Adrian! In BatchChildEditor.js you are using jQuery.size(). It's deprecated in jQuery 1.8 and on, so perhaps use the .length property? And also .load() handler - use .on('load', handler)

Edit Mode needs grid lines

When in edit mode, I think it would be beneficial to include some styling that adds grid row lines to match the look of the Lister Mode.

Here is how it looks without the lines:
image

Here is how it looks with the lines:
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.