Jump to content

PWaddict

Members
  • Posts

    908
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by PWaddict

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

  2. 46 minutes ago, bernhard said:

    Sorry, I don't understand what you are trying to do ? 20 + 20 + 10 would work? What is the reason for that request? What is "one upload"? I think you need to be more precise to get better answers.

    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.

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

     

  4. 12 minutes ago, kixe said:

    I think you don't need a workaround with a hidden field if you do the hook after and change the PageArray instead of the selector.

    
        $wire->addHookAfter('ProcessPageList::find', function($e) {
            $pages = $e->return;
            if ($pages->first()->parent->id != 111111) return; // quick exit if parent doesn't match
            $zeroDatePages = $pages->find("date=''"); // empty date pages
            $result = $pages->filter('date>0,sort=-date'); // pages with date, sort descending
            $result->prepend($zeroDatePages); // prepend empty date pages
            $e->return = $result;
        });

     

     

    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.

    • Like 1
  5. 2 minutes ago, LostKobrakai said:

    In MySQL `NULL` is always less then any non-null value. Therefore you either need to sort at runtime, somehow make the sql query issued sort by `ISNULL(col), col` with different directions or use my paginator module for paginating though multiple different selectors: https://github.com/LostKobrakai/Paginator

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

  6. 4 hours ago, kixe said:

    I use a hook for something similar
     

    
        /** CUSTOM PAGE SORT
         * related for InputfieldPageListSelect, ProcessPageList (Page tree)
         * 
         */
        $wire->addHookBefore('ProcessPageList::find', function($e) {
            $parent = $e->arguments(1);
            $selectorString = $e->arguments(0);
            // modify $selectorString, remove, modify, add ',sort= ...'
            $e->arguments(0, $selectorString);
        });

     

    Thanks for your reply but I don't understand how to sort the pages with empty date field on top...

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

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

     

  9. 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');
        }
    
    });

     

    • Like 1
×
×
  • Create New...