Jump to content


  • Content Count

  • Joined

  • Last visited

  • Days Won


Everything posted by PWaddict

  1. 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
  2. It seems that setMaxFiles is actually used for the maxFiles value (Maximum files allowed) under the Details tab of the file/image field.
  3. 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.
  4. Unless maxFiles & setMaxFiles are actually the same? I've read somewhere that setMaxFiles is max allowed files per upload.
  5. 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.
  6. 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
  7. @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.
  8. 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.
  9. 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...
  10. 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???
  11. Thanks for your reply but I don't understand how to sort the pages with empty date field on top...
  12. 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.
  13. 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'); });
  14. 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
  15. 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'); } });
  16. 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"); } }); 😞
  17. 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); });
  18. Thanks, this seems to work if I have 2 languages but it doesn't work if I have only 1 and I don't understand why cause it's the default language for both cases. I need it to work with 1 or additional languages.
  19. It doesn't work. The title field is still empty. $wire->addHookAfter("Pages::saveReady", function(HookEvent $event) { if($page->template->name != 'mytemplate') return; $defaultLang = wire("languages")->get("default"); $page->title->setLanguageValue($defaultLang, "New Value"); });
  20. How to manipulate page title on a hook after page save for ONLY the default language?
  21. On localhost where it's working properly I'm having 3 languages. On live server I have only 1 language and after I delete the other 2 additional languages on localhost the problem now happens there too.
  22. I'm using the following hook in site/ready.php to manipulate page title in admin section and it work fine in localhost but I just noticed that it doesn't work on live server. I'm always getting "Untitled" even though all 4 fields have values. $wire->addHookAfter("Pages::saveReady", function(HookEvent $event) { $page = $event->arguments[0]; if($page->template->name != 'mytemplate') return; if($page->myfield_text_a && $page->myfield_text_b && $page->myfield_options && $page->myfield_date) { $page->title = $page->myfield_text_a . ", " . $page->myfield_text_b . ", " . $page->myfield_options->title . ", " . $page->getFormatted("myfield_date"); } else { $page->title = "Untitled"; } }); How is this possible???
  • Create New...