Jump to content

Batch Child Editor


adrian

Recommended Posts

This is  a s lightly obscure issue, but hopefully very easy to deal with. If a page only has one child, then the child doesn't necessarily have a sort attribute. In this case, BatchChildEditor will add a sort attribute and save the page. This seems to me to be unnecessary (and is causing a small problem with a module of mine). Is it possible and reasonable to not set the sort if there is only one child?

The relevant code is at the end of the saveChildren() method:

$cp->sort = $i;

if($cp->isChanged()) {
    $cp->of(false);
    $cp->save();
}

I think it would need something like:

if($this->wire('input')->post->individualChildTitles->count() > 1) {
    $cp->sort = $i;
}

if($cp->isChanged()) {
    $cp->of(false);
    $cp->save();
}

but maybe there is a better solution?

  • Like 1
Link to comment
Share on other sites

Hi @MarkE - looking at the pages DB table, it seems that in reality I should just be setting the sort values starting at 0 and not 1. Not sure why I set it up this way - seems like generally it doesn't matter, but setting the first child page to 0 should work for you I believe. 

I have made that change for the latest version - can you let me know how it goes for you please?

  • Like 1
Link to comment
Share on other sites

Hi @virtualgadjo - it's only one language at a time IIRC. The problem with multiple is how to arrange the data in the export. Different users will need different layouts so it's best to generate these sorts of exports yourself. I tend to use AdminActions to create these sorts of custom imports.

  • Like 1
Link to comment
Share on other sites

hi @adrian

and thanks a lot for your answer, i'll try tu use AdminActionh for this too, didn't think of this although i often use AdminActions for many other purposes ?

i've solved my current problem using batch child for the fields i need in the default language adding the page id to the field list and using Ryan recent ProcessLanguageFieldExportImpor to export the multi language ones then i just had to agregate both csv based on the page ids

you're right, my first thought was to write my own code but pw does so many things "by itself it must have made me a little lazy ?

have a nice day
 

Link to comment
Share on other sites

  • 1 month later...

I'm trying to export to csv a list of current member users. There seems to be no way to do this without listerPro. Does Batch Child Editor allow you to export any admin pages?

/EDIT

I was looking in the wrong spot. I was looking for export function under Access > Users in the drop down on the top bar but when I went to Admin > Access > Users -- Edit in the page tree, I was able to make it work. For anyone looking for that functionality maybe that helps.

Thanks Adrian.

Link to comment
Share on other sites

Not sure what you are making work via Admin > Access > Users, because to get BCE to work here like that, I need to replace line 185 with:
 

        if(!$this->data['allowAdminPages'] && (!in_array($this->editedPage->id, $this->wire('config')->usersPageIDs) && ($this->editedPage->template->flags & Template::flagSystem))) return;

 

Link to comment
Share on other sites

54 minutes ago, adrian said:

Not sure what you are making work via Admin > Access > Users, because to get BCE to work here like that, I need to replace line 185 with:
 

        if(!$this->data['allowAdminPages'] && (!in_array($this->editedPage->id, $this->wire('config')->usersPageIDs) && ($this->editedPage->template->flags & Template::flagSystem))) return;

 

Don't know buddy, I guess you're just that good. ?

 

Screen Shot 2023-03-17 at 12.33.08 PM.png

Screen Shot 2023-03-17 at 12.33.46 PM.png

Link to comment
Share on other sites

  • 2 weeks later...

Hey Adrian,

New issue, different project. I set up a tracking system for a client that wanted to keep a record of all downloads of a certain file they offer on their site. Only logged in users can access the file and on download a page is created under user tracking showing the user name, date of dl etc.

They also wanted to export that list as a csv so I'm using Batch Child Editor to give them that function and it worked well for a while but now there's 6800 ish pages in user tracking and whenever they attempt to export it throws an error: Error: Exception: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away.

They are on shared hosting so resources are limited so I told them that with the csv they have they should delete the older pages but even that fails so I had to use phpMyAdmin.

Lister has no problem handling the volume but BCE does so are you aware of a limit to BCE and is there a way around it?

------------

I believe the issue is that the BCE editor is displaying all of the child pages at once and with so many, that's what chokes it. If it's possible to implement some kind of pagination it should fix the problem.

Edited by digitex
Link to comment
Share on other sites

  • 2 weeks later...

Hi @digitex - you're right about the displaying of all the child pages - this module really doesn't work well in edit with lots of children - poor design on my part :)

That said, I think if you disable edit mode for branches with lots of children, you should be able to offer the CSV export mode and I think it should be ok. It won't be as capable as Lister still because Lister batches exports whereas BCE tries to do all in one batch.

I really haven't used this module in a long time so I'm afraid I don't have much impetus to modify the export functionality, but hopefully it will work for you with edit mode disabled.

Link to comment
Share on other sites

  • 2 months later...
  • 5 months later...
On 12/13/2023 at 9:31 PM, adrian said:

The field pairings is only available from the Settings tab of those pages selected under Configurable pages. Does that help?

I want to update map data on City pages and I followed your instructions from here:

This is how my settings in city's parent page looks like:

659716071_Kepernyofoto2023-12-15-10_16_14.thumb.png.2f9d80c8a7cc583e76a64bf5b1b2026a.png

The format of the CSV what I uploaded:

City1 name,City1 name,41.88700499999999,-87.64885009999999
City2 name,City2 name,47.474851,20.5913671
City3 name,City3 name,79890229999999,20.0036779
...

After uploading the cities map data is empty. Could you help me?

 

Link to comment
Share on other sites

  • 1 month later...

Hey there,

I’ve been playing around with BCE. I love all its functionalities and will need it for a project very soon.

A quick question though : when in lister mode, you can define filters, and that’s great. But I could not find how to predefine blank filter. Imagine that my client will frequently use a filter on a field called "place". How can I get this filter ready to be filled, like "Place" + "contains texte like" + _blank_ ? Otherwise, he will always have to pick the right field and the right matching condition each time he lands on the page.
And BTW, is there any way to hide the filter "Parents" "equals" "id" ? Because this is implicit and my cause confusion to my client.

Many thanks in advance ?

Link to comment
Share on other sites

  • 1 month later...

Hi,

funny little problem; if i allow the users to modify the export settings and, for example just want to export the children IDs and titles, il doesn't export a csv at all but tables containing php errors
---
Notice: Trying to get property 'type' of non-object in D:\wamp\www\terrapixa\epifnew\site\assets\cache\FileCompiler\site\modules\BatchChildEditor\ProcessChildrenCsvExport.module.php on line 248
Notice: Trying to get property 'type' of non-object in D:\wamp\www\terrapixa\epifnew\site\assets\cache\FileCompiler\site\modules\BatchChildEditor\ProcessChildrenCsvExport.module.php on line 254
---

same thing if i just try to add the ids to the original field list

funny enough, everything works like a charm if i delele this user permission, nice csv as the output but, too bad, without the children ids ?

have a nice day


---

  • Like 1
Link to comment
Share on other sites

I am confused by your response - you can write a module to do it if you want, but the problem you had with those errors should now be fixed, so you should be able to use this module now.

  • Thanks 1
Link to comment
Share on other sites

Hi again @adrian

wow, faster than the light speed, just downloaded the last release and, yes, it works really well, thanks so much!!!

and, you know, don't be confused by my response, it's just that i thought you may have something else to do than reacting that fast, i'm stunned and at the same time it's so pw like ? i should be used to it

thank you very much again and have a nice day, mine is even nicer, saved some time thanks to you ?

  • Like 2
Link to comment
Share on other sites

  • 1 month later...

Hi, here again ?

i'm running into a funny little issue
on a website that has a page with many children (714 so far), some of them hidden, some not, some of them already unpublished, some not, if i try to unpublish all the children i get this error
--

ProcessPageEdit: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicata du champ 'weekendatbinnys-champagne-tasting-1021' pour la clef 'name1019_parent_id'
--
the funny thing being that using your admin actions module, i've created my own action to unpublish all those pages (that have the same template), just adding include=all to my find

protected function executeAction() {
    $ps = $this->wire('pages')->find('template=un_event, include=all');
    foreach($ps as $p) {
        $p->addStatus(Page::statusUnpublished);
        $p->save();
    }
    return true;
}

it works like a breeze ? so, actually not really a problem for me but just for you to know ?
the other funny thing is if i try to "repuiblish" all of them using the batch child editor i get this error again and... it only "republishes" the pages that were hidden at the beginning of the loop (it's a real life website and the client often "plays" with the page status along the events validation) this tends to make me think it's an include thing somewhere

this makes me think too that i may go a little further with this custom action to let choose the pages to unpublish/publish by their template, parent, and so on

and, of course, thanks again for those modules i really like playing with ?

have a nice day

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