Jump to content

MaierGrem

Members
  • Posts

    16
  • Joined

  • Last visited

Everything posted by MaierGrem

  1. @Robin S @tpr ?‍♂️ thanks...))
  2. @tpr, could you add the option "use custom fields width" to the Uikit Tweaks section? When this option is enabled, the css file should be added after uikit in which there will be classes in the format: @media (min-width: 960px) { [data-colwidth="1\%"] { width: 1%; } [data-colwidth="2\%"] { width: 2%; } ... [data-colwidth="100\%"] { width: 100%; } } This will solve the problem - https://github.com/processwire/processwire-issues/issues/480
  3. Has anyone encountered such a problem? When you generate WEBP via $image->webp (IMagick Image Sizer enabled), files are created, but they are not valid. Accordingly, they do not open in the browser. These files look quite functional, but are not displayed. I can’t understand what kind of images can go bad during generation. I took one image, generated it in the same formats to get a working webp and a broken one. Google Chrome in the console displayed loading webp images, but did not display it. I downloaded both files. Comparing the files that I discovered a size mismatch for the generated WEBP files. File sizes differed by only 1 byte. screenshot. With the help of the HEX editor I looked at what was missing there. It turned out that during the generation of PHP does not append 1 byte to the end of the file, the file is not valid and Chrome can not display it. Working file; Broken file; Having studied the structure of WEBP a bit, I came to the conclusion that all live files always end with byte x00, in addition WEBP continues to work fine if you add any number of x00 to the end. You can check it yourself, everything works fine. $image = $page->images->first(); $resized = $image->size(1600, 960); $webp = $resized->webp->url; $file = fopen($webp, "a+"); fwrite($file, chr(0x00)); fclose($file);
  4. @Robin S - thank you very match!!! The solution as I wanted!
  5. @Robin S - thanks for answer! It's work! Solution: 1. Hook before ProcessPageEdit::processInput in which I make fields not required. 2. Hook after Pages::save in which I remove page (profile) and user. But there are a couple of points: 1. In ProcessPageEdit::processInput hook, accessing wire('pages')->delete($page) does not work. 2. How can I get all the fields in the $form, so that through the function each make them not required? 3. Is it possible to somehow combine this into one hook? Could it be calling Pages::save in ProcessPageEdit?
  6. @wbmnfktr, okey, here is my code in ready.php: $this->addHookAfter('Pages::save', null, 'deleteUserAccount'); function deleteUserAccount(HookEvent $event) { // bd('deleteUser'); $page = $event->arguments('page'); $template = $page->template; $profiles = [ 'member', 'editor', 'administrator', 'supervisor' ]; if (in_array($template, $profiles)) { if ($page->delete && $page->delete_confirm === 'DELETE') { $user = wire('users')->get($page->user_id); if ((bool) $user->id) wire('users')->delete($user); $message = "Profile and user deleted."; wire('notices')->add(new NoticeMessage($message)); wire('pages')->delete($page); wire('session')->redirect('/admin'); } } } ProcessWire version 3.0.139. I tried the hooks: After/Before Pages::saveReady After Pages::save After Pages::saved After redirect everywhere notifications of required fields appear. And this is logical, because the page is then saved without data. When there is data, then everything works as it should. But if the profile was created by mistake, and you need to delete it without filling in the fields, then you do not need to show notifications.
  7. @wbmnfktr, thanks for answer! i'll check this functionality without required fields, and all work. I can not figure out at what point the system generates notifications of mandatory fields. With the standard function of moving to the basket, fields are not checked. And when removed from the basket too.
  8. @PWaddict Maybe, in the module, enable the Rename parameter when saving, and if the repeater element was created after the loaded image, it can affect the file renaming? presumably ..) I would also advise you to look at the module code, there is a function that is written specifically for repeaters. I would test the save order via tracy debugger.
  9. How can I make a custom page deletion? I made the checkbox delete, the confirmation field delete_confirm, into which I need to enter the word “DELETE” and the text field to describe the reason for the removal .. The form has the required fields first, middle, last name. I tried different hooks (after &before pages::saveReady, save, saved e.t.c), which checks the delete, delete_confirm fields, create notify in session and redirect to the root in the admin panel. All used hooks gave the same result. The page is deleted, but warnings are displayed that the fields first, middle, last name is required .. How to intercept events and which hook is better to use to implement such deletion?
  10. @Robin S Thanks for reply! That's exactly what I did. But only the && operator, because I don't need to automatically send a notification. The administrator must know that he has notified the user. If he forgot to check the notify_user checkbox, then after saving the page I will not be able to track categories changes.. The notification describes which categories have been deleted, which have been added, etc. if ($template == 'member') { $old = clone($page); $old->uncache(); $changed = WireArray(); $fields = ['categories']; foreach($fields as $fieldname) { if ($page->isChanged($fieldname)) { $changed->set($fieldname, $old->$fieldname); } } if ($changed->has('categories')) { $categories = WireData(); $categories->set('current', PageArray()); $categories->set('added', PageArray()); $categories->set('removed', PageArray()); foreach ($old->categories as $category) { if (!$page->categories->has($category)) { $categories->removed->add($category); } else { if (!$categories->current->has($category)) $categories->current->add($category); } } foreach ($page->categories as $category) { if (!$old->categories->has($category)) { $categories->added->add($category); } else { if (!$categories->current->has($category)) $categories->current->add($category); } } bd($categories->current, 'current'); bd($categories->added, 'added'); bd($categories->removed, 'removed'); } } This code in Hook after Pages::saveReady..
  11. Question to professionals) I use the "Page Reference" field (name = categories, types = multiple, asm-select) and checkbox field (name = notify_user). When editing the page, I need to check if: - (categories) values has changed (deselected one or more current pages), make (notify_user) required. - (categories) values has changed (selected one or more new pages), make (notify_user) required. - (categories) values don't change, then the (notify_user) is not required. I tried to make a condition, required if: 1. "categories!=1020|1490" - does not work. 2. "categories!=1020|1490, categories.count != 2" - does not work. 3. "categories%=1020|1490 - js error. Please advise how best to solve this problem.
  12. You can install TracyDebugger and you can test it. Also see the developer tools in the browser. Perhaps there you will find the cause.
×
×
  • Create New...