-
Posts
926 -
Joined
-
Last visited
-
Days Won
1
Everything posted by PWaddict
-
I'm creating this post to help any Kaspersky Antivirus owners that will experience the following problem if their server supports HTTP/2: Trying to upload multiple images at once in ProcessWire suddenly became a nightmare. I was getting this error multiple times for some of the images: POST https://www.mysite.com/admin/page/edit/?id=10097&InputfieldFileAjax=1 net::ERR_HTTP2_PROTOCOL_ERROR and sometimes these ones too: POST https://www.mysite.com/admin/page/edit/?id=10097&InputfieldFileAjax=1 502 Uncaught SyntaxError: Unexpected token < in JSON at position 0 at JSON.parse (<anonymous>) at Function.parseJSON (JqueryCore.js?v=183:2) at XMLHttpRequest.<anonymous> (InputfieldImage.min.js?v=123-1599567437:1) Few months ago I've installed Kaspersky Security Cloud on my PC and today when I was checking the SSL certificates on my sites and on third-party sites including ProcessWire I noticed it was saying "Issued by: Kaspersky Anti-Virus Personal Root Certificate". I opened Kaspersky Security Cloud and went to Settings > Additional > Network and I selected "Do not scan encrypted connections" under "Encrypted connection scanning". By default the selected option is "Scan encrypted connections upon request from protection components". Problem solved. I can finally upload multiple images at once again and view the original issuers of the website's SSL certificates.
-
How to set maximum image files upload at once with hook?
PWaddict replied to PWaddict's topic in API & Templates
Now, I'm getting more errors besides the one I mention above. You can delete this topic and if I can't figured out the problem I will create a new proper topic with all the details. -
How to set maximum image files upload at once with hook?
PWaddict replied to PWaddict's topic in API & Templates
Please delete this topic. -
How to set maximum image files upload at once with hook?
PWaddict replied to PWaddict's topic in API & Templates
Ok something else is going on. On localhost where PHP has max_file_uploads = 20 too (same as live server) I tried to upload 22 images at once and it worked fine. On live server when I tried to upload the same 22 images I got 13 identical errors in chrome console and 13 images stuck at "uploading" forever... Failed to load resource: net::ERR_HTTP2_PROTOCOL_ERROR -
How to set maximum image files upload at once with hook?
PWaddict replied to PWaddict's topic in API & Templates
It seems that setMaxFiles is actually used for the maxFiles value (Maximum files allowed) under the Details tab of the file/image field. -
How to set maximum image files upload at once with hook?
PWaddict replied to PWaddict's topic in API & Templates
My php default shared server settings have max_file_uploads = 20 so I would like to limit to 20 in ProcessWire too cause if I upload for example 30 images at once only the 20 will be uploaded. The other 10 will look like they're uploading forever and this is confusing for the editors. So, is it possible to limit it to 20 in ProcessWire or should I increase the number of max_file_uploads? Also, If I increase it wouldn't be bad for the server performance? Like with "setMaxFilesize" you're getting a warning on ProcessWire that you're not allowed for example to upload a file with size more than what you've set in "setMaxFilesize", I wanna do the same thing for the maximum files the editor can upload at once. I wanna let him upload max 20 and when those 20 uploaded he should be able to upload 20 max more and so on. -
How to set maximum image files upload at once with hook?
PWaddict replied to PWaddict's topic in API & Templates
Unless maxFiles & setMaxFiles are actually the same? I've read somewhere that setMaxFiles is max allowed files per upload. -
How to set maximum image files upload at once with hook?
PWaddict replied to PWaddict's topic in API & Templates
This just sets field to accept ONLY 20 images. What I'm looking for is let the editor upload 20 images per upload. If he wants to upload 50 images I don't want to let him upload them all at once. -
I'm trying to set maximum image files per upload with the following hook: $wire->addHookBefore('InputfieldImage::render', function(HookEvent $event) { $inputfield = $event->object; $inputfield->setMaxFiles(20); }); but when I go to edit a page with Images fields I'm getting the following error: ProcessWire: ProcessPageEdit: Method InputfieldImage::setMaxFiles does not exist or is not callable in this context
-
@horst Am I using the wrong hook for setMaxFiles? Sorry my mistake. When I try to edit a page with Images field I'm getting the error saying about "method InputfieldImage::setMaxFiles does not exist etc. So this isn't related to your module.
-
[SOLVED] How to sort pages on top when the sort date field is empty?
PWaddict replied to PWaddict's topic in API & Templates
That works great on backend but on frontend I have to change the code on various pages to get the same results. I think I'm gonna do the hidden field method where I only have to change the sort. Thanks for the help. -
[SOLVED] How to sort pages on top when the sort date field is empty?
PWaddict replied to PWaddict's topic in API & Templates
I've created a checkbox field named "nodate" and I checked it on a page with empty date field. Then on the above hook added the sort like this: sort=-nodate, sort=-date It seems to be working properly. Now I have to make the nodate checkbox field hidden and automatically checked on save when the editor leaves empty the date field... -
[SOLVED] How to sort pages on top when the sort date field is empty?
PWaddict replied to PWaddict's topic in API & Templates
With the above hook that @kixe posted I can add multiple selectors too. I'm using 1 date field to sort pages by date but if the date is empty I want that page to be sorted on top. What's the proper selector for that??? -
[SOLVED] How to sort pages on top when the sort date field is empty?
PWaddict replied to PWaddict's topic in API & Templates
Thanks for your reply but I don't understand how to sort the pages with empty date field on top... -
I would like to sort pages of specific template with a date field. The problem is that the date field might not always be filled by the editor cause he might not know yet what date to set. So, all the pages with a date should be sorted by it and those that have empty dates should sort on top. Setting the date field on the template's "Sort settings for children" sorts pages with empty dates on bottom.
-
Try this in your site/ready.php: // if hook "added" isn't working try "save" $this->pages->addHookAfter('added', function($event) { $page = $event->arguments[0]; if($page->template != 'your-child-template') return; $page->setAndSave('title', 'Your Title'); });
-
I'm trying to set maximum image files per upload with the following hook: $wire->addHookBefore('InputfieldImage::render', function(HookEvent $event) { $inputfield = $event->object; $inputfield->setMaxFiles(20); }); but when I go to edit a page with Images or CroppableImage3 fields I'm getting the following error: ProcessWire: ProcessPageEdit: Method InputfieldCroppableImage3::setMaxFiles does not exist or is not callable in this context
-
This works properly: $this->pages->addHookAfter('save', function($event) { $page = $event->arguments[0]; if($page->template != 'mytemplate') return; if($page->venue && $page->city && $page->country && $page->date) { $page->setAndSave('title', $page->venue . ", " . $page->city . ", " . $page->country->title . ", " . $page->getFormatted("date")); } else { $page->setAndSave('title', 'Untitled'); } });
-
If I use the following hook, with 2 languages works fine but with 1 language I have to press the Save button twice for the title field to get updated: $wire->addHookBefore('ProcessPageEdit::processInput', function(HookEvent $event) { $page = $event->object->getPage(); if($page->template == "mytemplate") { $page->title = $page->venue . ", " . $page->city . ", " . $page->country->title . ", " . $page->getFormatted("date"); } }); ?
-
That was I'm trying and it works but it doesn't work with only just 1 language when using fields to get the title value. $wire->addHookBefore("Pages::saveReady", function(HookEvent $event) { $page = $event->arguments(0); if($page->template->name != 'mytemplate') return; if(count(wire("languages")) > 1) { $defaultLang = wire("languages")->getDefault(); $page->title->setLanguageValue($defaultLang, $page->venue . ", " . $page->city . ", " . $page->country->title . ", " . $page->getFormatted("date")); } else { $page->title = $page->venue . ", " . $page->city . ", " . $page->country->title . ", " . $page->getFormatted("date"); } $event->arguments(0, $page); });