Jump to content

Batch Child Editor


adrian

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.

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

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

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

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

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

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

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

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

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

  • 2 months later...

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

Link to comment
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 :)

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

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