Jump to content
adrian

Batch Child Editor

Recommended Posts

Thanks Adrian, great module!

I'm trying to use it to export users page into csv, but the module doesn't show in "Users" parent page.

Is there a way to make it work?

Glad you like it!

Are you talking about from Access > Users, or Home > Admin > Access > Users ?

The former uses Lister, so I assume you are talking about the latter. If you have ListerPro you can use the export to CSV action from the former. If you don't, then go into the BCE module code and comment out this line:

// don't even consider system templates
if($this->editedPage->template->flags & Template::flagSystem) return;

On the master branch it is line#159 and on dev it is 166.

Let me know if that works for you.

I wouldn't recommend leaving this commented though - I haven't though through it too much, but the Replace mode could cause some major damage pretty quickly :)

Do you need this to be available regularly, or is it a one off need? If you need it regularly I could add any exception for the user page - let me know and we'll work something out.

Share this post


Link to post
Share on other sites

I have bunch of Pages that have

I'm

in their title. BCE doesn't show them correctly, only the "I' is visible under the "TITLE" column. I can add titles correctly and they gets saved (fortunately). I guess it's a bug.

post-3156-0-88262100-1446551581_thumb.pn

Update:

On second save (when title field shows "I" only) the wrong value gets saved.

Share this post


Link to post
Share on other sites

Thanks @adrian

yes i was talking about Home > Admin > Access > Users

Unfortunately i've commented that line, and i can see the Batch Child Editor block in Children Tab, but when i click on export csv nothing happen

And yes i need this to be available regularly to export users.

Thanks for helping.

Share this post


Link to post
Share on other sites

I have bunch of Pages that have

I'm

in their title. BCE doesn't show them correctly, only the "I' is visible under the "TITLE" column. I can add titles correctly and they gets saved (fortunately). I guess it's a bug.

attachicon.gifbce-i-am-bug.png

Update:

On second save (when title field shows "I" only) the wrong value gets saved.

Thanks for reporting @tpr - I have fixed this on the master branch. I have some uncommitted changes to the dev branch at the moment, so the fix won't be on that branch just yet.

  • Like 1

Share this post


Link to post
Share on other sites

Thanks! Just tried and it works fine.

BCE and Migrator saved my *ss today when I needed to migrate 100+ pages, so thanks for these :)

  • Like 1

Share this post


Link to post
Share on other sites

@tpr - glad it works and that Migrator helped to save your *ss too :)
 
 

Thanks @adrian
 
yes i was talking about Home > Admin > Access > Users
 
Unfortunately i've commented that line, and i can see the Batch Child Editor block in Children Tab, but when i click on export csv nothing happen
 
And yes i need this to be available regularly to export users.
 
Thanks for helping.

 
Firstly, I do have a working solution for you, but first a little background :)
 
It is weird that nothing is getting exported - it is definitely exporting a valid CSV file for me. The only problem I am seeing is that I can't control the fields that are exported - it is defaulting to: Set Password, Email Address, Roles
 
The problem is that if you allow the Home > Admin > Access > Users to be separately configurable you should be able to specify the required fields, but the settings don't save, because that page is locked for editing by PW so we are out of luck with that.
 
BUT, here is my working solution, which I think is cleaner than making users navigate to that deep page anyway:

  • Grab the latest master version (there is one critical change to make this work).
  • Create a new page somewhere in the main page tree (not inside the Admin tree) - maybe called "User CSV Export".
  • Make this new page separately configurable in the BCE "Where editing tools are available and separately configurable" settings section.
  • Go to the Settings tab of this new page and configure it to enable Export mode.
  • In the Content / Deletion / Protection section, set the Parent Page to: Home > Admin > Access > Users
  • In the CSV Export Settings, set up the fields to export. You will likely want Name, Email Address, and any custom fields you may have set up.
  • Save settings and then go to where you have BCE displayed (maybe an Inline Fieldset would be a good idea in this case) and click Export.

Works great here, so please test and let me know.

  • Like 2

Share this post


Link to post
Share on other sites

Thanks @adrian .

I'm trying the solution you described. I don't know if I'm doing something wrong but the "Fields to export" select is not showing the user template fields.

I made some screenshot of the setting tab and of the "field to export" select.

The editor is giving me some problem attaching them so here are the links to the screenshots

https://www.dropbox.com/s/16oqik2ann07y40/settings_tab.png?dl=0

https://www.dropbox.com/s/c0h2gvgty27k3uw/Schermata%202015-11-04%20alle%2009.57.46.png?dl=0

Share this post


Link to post
Share on other sites

Ah - sorry - at the moment you will need to check the "User override CSV settings" and then choose the fields to export when going to actually export - does that make sense.

post-985-0-52802100-1446629232_thumb.png

I'll see what I can do about getting the correct fields to also appear in the config settings based on the selected alternate parent page.

Share this post


Link to post
Share on other sites

It seems I have no luck here. I check "Users override CSV settings", then save, but when the page load again "Users override CSV settings" is still unchecked

Share this post


Link to post
Share on other sites

Ok, I just committed a new version (master branch again) that will grab the fields from the selected alternate page (you need to save the page after selecting an alternate parent page to refresh the field list), so you should now be able to set those in  the config settings and not rely on doing it at export. Does this work for you like this?

post-985-0-87894700-1446630925_thumb.png

As for why your override checkbox is not saving, I am completely baffled - do you have debug mode on? Any errors? It looks like all the other settings on that page are saving - correct?

Share this post


Link to post
Share on other sites

Not sure what's about that, but I tried this module and now I get on every page save I see message "Session: Change: status". Took me a while to realize it's BatchChildEditor.

  • Like 1

Share this post


Link to post
Share on other sites

Not sure what's about that, but I tried this module and now I get on every page save I see message "Session: Change: status". Took me a while to realize it's BatchChildEditor.

Thanks for spotting Soma - it seems to come from this code:

            // temporarily put the parent in an unpublished status so that we can check it from
            // the proper context: when page-publish permission exists, a page not not editable
            // if a user doesn't have page-publish permission to it, even though it may still
            // be editable if it was unpublished.
            $parent->addStatus(Page::statusUnpublished);
            $parentEditable = $parent->editable();
            $parent->removeStatus(Page::statusUnpublished);

This is part of a method called getAllowedTemplatesAdd that determines whether the user is allowed to add a template to this parent. It is a modified version of this method: https://github.com/ryancramerdesign/ProcessWire/blob/cffb682836517065d7dd7acf187545a4a80f1769/wire/modules/Process/ProcessPageAdd/ProcessPageAdd.module#L191

I am not sure how to avoid this check. Do you think it is a major concern? I guess it's not ideal that there is a recorded change to a page when saved, even though there are effectively no changes.

Any thoughts?

  • Like 1

Share this post


Link to post
Share on other sites

Why is this needed to change Status and back I don't get it? I don't think it's nice if it's tracked. What if I track changes to my pages? So maybe a trackChange(false) is needed?

Share this post


Link to post
Share on other sites

Just tried a 

$parent->setTrackChanges(false);
$parent->addStatus(Page::statusUnpublished);
$parentEditable = $parent->editable();
$parent->removeStatus(Page::statusUnpublished);
$parent->setTrackChanges(true);
and it wouldn't track it. I think it's something we want to hide from the track change system. What if I'm listening to page changes in my module? :)
 
Edit1: I noticed recently that there's really a lot of such changes going on in PW. Only opening a page editor does change the created_users_id for example. Huh? 
 
Edit2: well I guess it's because I'm tracking every change to page object, so I guess there's maybe some way around it (using page type, template etc, and fields). But still I think such back and forth changing to archive something, those should be hidden from track changing. What you think?
  • Like 1

Share this post


Link to post
Share on other sites

I think that setting TrackChanges to false seems like a great idea - I will happily implement that in BCE - do you want to suggest it to Ryan for the core version of that method?

I noticed recently that there's really a lot of such changes going on in PW. Only opening a page editor does change the created_user_id for example. Huh? 

Just to clarify - this is PW core changes you are talking about and not something caused by BCE - correct?

Share this post


Link to post
Share on other sites

I would suggest it to Ryan see what he thinks.

Sorry, no this is core and not BCE.

  • Like 1

Share this post


Link to post
Share on other sites

I would suggest it to Ryan see what he thinks.

Sorry, no this is core and not BCE.

Great - just committed a new version of BCE (master branch) with those changes - thanks for figuring this out!

  • Like 1

Share this post


Link to post
Share on other sites

Ehrm I'm not sure it's really correct code. :) Just trying to get my head around it. $page->setTrackChanges(false) isn't correct but it may have an effect to clear out changes? Sorry for the confusion.


Lol I'm so stupid, looking at the wrong method in Wire.php, no it's ok I guess. :) Sorry again.

Share this post


Link to post
Share on other sites

Lol I'm so stupid, looking at the wrong method in Wire.php, no it's ok I guess. :) Sorry again.

No problem - it looks like that approach of setting to false, doing something, and then setting to true is used in several places in the PW core. Interestingly, the cheatsheet mentions setting to false, but doesn't show true as an option - maybe just meant to be assumed - weird it doesn't show:

$a->setTrackChanges(true|false)

That would be consistent with others.

Share this post


Link to post
Share on other sites

I was about to change it on cheatsheet. But now it's because it's only a set and default is ON. Hence there's two entries in cheatsheet and not (true|false).


So a 

$parent->setTrackChanges(false);

...

$parent->setTrackChanges();

would be sufficient.

  • Like 1

Share this post


Link to post
Share on other sites

Just wanted to let you guys know that I have committed some changes over the last couple of days that brings complete live updating of child page details (name, template, hidden status, unpublished status, and removal of a row if deleted) in the edit mode table after making edits to a specific page in a modal popup.

It might not seem like much, but it makes this mode much more functional and intuitive.

Please let me know if you notice any problems.

  • Like 4

Share this post


Link to post
Share on other sites

Are admin pages disabled by default? I have a few pages under the Admin branch (form submissions) and BCE doesn't seem to be present there. Is there a way to allow it there?

(using devns 3.0.5)

Share this post


Link to post
Share on other sites

Are admin pages disabled by default? I have a few pages under the Admin branch (form submissions) and BCE doesn't seem to be present there. Is there a way to allow it there?

(using devns 3.0.5)

Yes they are disabled by default, but I just added a new option under Content / Deletion / Protection to enable BCE editing of the Admin page branch.

Obviously this has the potential to completely break a PW install so use carefully at your own risk :)

Share this post


Link to post
Share on other sites

Hi Adrian!

When I mark children page for delete and then Save the page, I get errors (see attachment). The page itself (http://localhost/processwire/page/edit/?id=1) returns " The process returned no content." Could it be my fault (playing around...)? No problem with editing and adding pages.

Thanks for the report and sorry about that - looks like I introduced a bug in my commits from yesterday. Should be fixed now in the latest version. Please let me know if you still have any problems.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By eelkenet
      Hi! I've created a small Inputfield module called InputfieldFloatRange which allows you to use an HTML5 <input type="range" ../> slider as an InputField. I needed something like this for a project where the client needs to be able to tweak this value more based on 'a feeling' than just entering a boring old number. Maybe more people can use this so I'm hereby releasing it into the wild.  
       
      What is it?
      The missing range slider Inputfield for Processwire. 
      What does it do?
      This module extends InputfieldFloat and allows you to use HTML5 range sliders for number fields in your templates.
      It includes a visible and editable value field, to override/tweak the value if required.  
      Features
      Min/max values Precision (number of decimals) Steps (Read more) Manual override of the selected value (will still adhere to the rules above) Usage
      Clone / zip repo Install FieldtypeFloatRange, this automatically installs the Inputfield Create new field of type `Float (range)` or convert an existing `Float`, `Integer` or `Text` field. To render the field's value simply echo `$page->field` Demo
      A field with Min=0, Max=1, Step=0.2, Precision=2

      Field with settings Min=0, Max=200, Step=0.25, Precision=2

       
      Todo
      Make the display-field's size configurable (will use the Input Size field setting)  Hopefully become redundant If it's usable for others I'll add it to the Modules list  
      Changelog
      v002
      - Fix issue where setting the step value to an empty value created problem with validation
      - Make the display-field optional 
      v001
      - Initial release
       
      Thanks!
       
       
    • By Robin S
      Another little admin helper module...
      Template Field Widths
      Adds a "Field widths" field to Edit Template that allows you to quickly set the widths of inputfields in the template.

      Why?
      When setting up a new template or trying out different field layouts I find it a bit slow and tedious to have to open each field individually in a modal just to set the width. This module speeds up the process.
      Installation
      Install the Template Field Widths module.
      Config options
      You can set the default presentation of the "Field widths" field to collapsed or open. Field widths entered into the Template Field Widths inputfield are only applied if the Edit Template form is submitted with the Template Field Widths inputfield in an opened state. "Collapsed" is the recommended setting if you think you might also use core inputs for setting field widths in a template context. You can choose Name or Label as the primary identifier shown for the field. The unchosen alternative will become the title attribute shown on hover. You can choose to show the original field width next to the template context field width.  
      https://github.com/Toutouwai/TemplateFieldWidths
      https://modules.processwire.com/modules/template-field-widths/
    • By adrian
      Tracy Debugger for ProcessWire
      The ultimate “swiss army knife” debugging and development tool for the ProcessWire CMF/CMS

       
      Integrates and extends Nette's Tracy debugging tool and adds 35+ custom tools designed for effective ProcessWire debugging and lightning fast development
      The most comprehensive set of instructions and examples is available at: https://adrianbj.github.io/TracyDebugger
      Modules Directory: http://modules.processwire.com/modules/tracy-debugger/
      Github: https://github.com/adrianbj/TracyDebugger
      A big thanks to @tpr for introducing me to Tracy and for the idea for this module and for significant feedback, testing, and feature suggestions.
    • By adrian
      This module allows you to automatically rename file (including image) uploads according to a configurable format
      This module lets you define as many rules as you need to determine how uploaded files will be named and you can have different rules for different pages, templates, fields, and file extensions, or one rule for all uploads. Renaming works for files uploaded via the admin interface and also via the API, including images added from remote URLs.   Github: https://github.com/adrianbj/CustomUploadNames
      Modules Directory: http://modules.processwire.com/modules/process-custom-upload-names/
      Renaming Rules
      The module config allows you to set an unlimited number of Rename Rules. You can define rules to specific fields, templates, pages, and file extensions. If a rule option is left blank, the rule with be applied to all fields/templates/pages/extensions. Leave Filename Format blank to prevent renaming for a specific field/template/page combo, overriding a more general rule. Rules are processed in order, so put more specific rules before more general ones. You can drag to change the order of rules as needed. The following variables can be used in the filename format: $page, $template, $field, and $file. For some of these (eg. $field->description), if they haven't been filled out and saved prior to uploading the image, renaming won't occur on upload, but will happen on page save (could be an issue if image has already been inserted into RTE/HTML field before page save). Some examples: $page->title mysite-{$template->name}-images $field->label $file->description {$page->name}-{$file->filesize}-kb prefix-[Y-m-d_H-i-s]-suffix (anything inside square brackets is is considered to be a PHP date format for the current date/time) randstring[n] (where n is the number of characters you want in the string) ### (custom number mask, eg. 001 if more than one image with same name on a page. This is an enhanced version of the automatic addition of numbers if required) If 'Rename on Save' is checked files will be renamed again each time a page is saved (admin or front-end via API). WARNING: this setting will break any direct links to the old filename, which is particularly relevant for images inserted into RTE/HTML fields. The Filename Format can be defined using plain text and PW $page variable, for example: mysite-{$page->path} You can preserve the uploaded filename for certain rules. This will allow you to set a general renaming rule for your entire site, but then add a rule for a specific page/template/field that does not rename the uploaded file. Just simply build the rule, but leave the Filename Format field empty. You can specify an optional character limit (to nearest whole word) for the length of the filename - useful if you are using $page->path, $path->name etc and have very long page names - eg. news articles, publication titles etc. NOTE - if you are using ProcessWire's webp features, be sure to use the useSrcExt because if you have jpg and png files on the same page and your rename rules result in the same name, you need to maintain the src extension so they are kept as separate files.
      $config->webpOptions = array(     'useSrcExt' => false, // Use source file extension in webp filename? (file.jpg.webp rather than file.webp) ); Acknowledgments
      The module config settings make use of code from Pete's EmailToPage module and the renaming function is based on this code from Ryan: http://processwire.com/talk/topic/3299-ability-to-define-convention-for-image-and-file-upload-names/?p=32623 (also see this post for his thoughts on file renaming and why it is the lazy way out - worth a read before deciding to use this module). 
       
       
      NOTE:
      This should not be needed on most sites, but I work with lots of sites that host PDFs and photos/vectors that are available for download and I have always renamed the files on upload because clients will often upload files with horrible meaningless filenames like:
      Final ReportV6 web version for John Feb 23.PDF

×
×
  • Create New...