Jump to content

froot

Members
  • Posts

    683
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by froot

  1. I thought about that too, but I doubt that solves the bug or what it is. Also, it's not like the admin template is listed among all other templates for me to edit.
  2. PW 3.0.200 PHP 7.3 MySQL 5.7 if that helps
  3. in one PW project of mine, none of them work. I mean name any module that shows a pagination in the admin backend and the pagination doesn't work, core or site module. My guess is it has to do with some sort of redirect somewhere though I cannot make out where and why. Lister Pro module for example at least shows an error: {"error":false,"message":"Unknown Lister action"}
  4. but why don't the links work? And what about other modules that use pagination in the admin backend, why does their pagination not work either and do they not use Process class?
  5. OK but does it work when you click on 2, 3, 4… ? Cause I get it to look as in your demo but the links don't work. What are you doing differently?
  6. I'm having difficulties paging/paginating an array of pages inside a process module. (template "admin") In the frontend, this seems to be more straightforward, but in admin, it seems to not know the segments. It shows the pager, it limits the results, however when I click on the next or any page it says "ProcessWire: Unrecognized path" and "Der Prozess hat keinen Inhalt ausgegeben." or something. The URL adds the segment /Seite2/ I thought I'd just have to allow pagination and segments in the settings of the listed pages's template, like I'm used to, but no, there must be more to it. Has anyone been there? Also, in other modules (not mine) I can see the pagination not working either. If I click on another page inside the pager, it reloads the same page.
  7. thanks @gebeer that sounds promising, will give this a try. Follow-up question: Is there a way to switch the email sender method by API? (I very much guess so) Once the quota is reached, I’d like to try sending over the web server. So far couldn’t accomplish that.
  8. just curious, how is a InputfieldCheckbox field different to a FieldtypeOptions field with only one option?
  9. I need to just set it once for an array of pages because the checkbox field would be new to them. After that the checkbox field would be set upon page creation. I'll give the Tracy Debugger option a try then. Thanks @gebeer!
  10. a checkbox field cannot be checked by default? also: Admin Action "Field Set or Search and Replace" cannot batch set a checkbox field's value? 😑
  11. thanks but no other service should be used. I just want to know if it's technically possible to know if an email was actually sent. I thought ->getResult() or the like would return an object of some sort.
  12. my SMTP-server has a limited amount of emails that it can send per day. Is there a way to find out if an email was actually sent or not?
  13. I have a field of type float and when I populate it with say 12.34 and save, the value changes to 12,34 In the frontend, it also outputs 12,34 which is NaN What to do? Weirdly, the same setup works on my localhost (outputs a float 12.34 in the frontend) but NOT on the remote server.
  14. if ($item->$field >= 0 && $item->$field !== '') { this did the trick, thanks a lot for the input @Jan Romero
  15. this is simply not true, for floats at least, it does NOT make a difference between 0 and empty value 😞
  16. And then also, there's one scenario where the value IS indeed 0, and NOT empty. So I need the condition to be true if the field value is literally 0 and not true if the field is actually not populated. if ($item->$field >= 0) { … } // this is true even if the field is not populated – not expected if ($item->$field >= 0 && $item->$field != '') { … } // this is false even when the field value is actually 0 – not expected if ($item->$field != '') { … } // this is false even when the field value is actually 0 – not expected It seems like which ever way I twist and turn it, I can't get it right. (I realise this is now off topic because I'm not even using the ->parent() API with selector anymore, because it seems to make this matter even harder)
  17. right, don't know how that happened… thanks! However, it's not just that. I have a float field on the template and on the parent and grandparent template. I set the field's settings to differentiate between empty and 0. So 0 and '' are NOT the same. I leave the field empty on the template. then when I do… function findValue($item, $field) { if ($item->$field >= 0) { // should not meet condition because field is empty and not 0 nor bigger return $item->$field; } else { $parent = $item->parent("$field!=", true); if ($parent != null) { return $parent->$field; } } return null; } it always goes to the if-code-block, how can that be?
  18. can't get my code to effectively use ->parents() API I have this function function getSingleValue($item) { $foo = findValue($item, "foo"); return $foo; } and then this one, but it doesn't work with the selector function findValue($item, $field) { if (isset($item->$field) && $item->$field != '') { return $item->$field; } else { $parent = $item->parents("$field!=", true); if ($parent != null) { return $parent->$field; } } return null; } echo getSingleValue('bar'); // my expected value however, with the loop, it works: function findValue($item, $field) { if (isset($item->$field) && $item->$field != '') { return $item->$field; } else { $parents = $item->parents(true); foreach($parents as $parent) { if (isset($parent->$field) && $parent->$field != '') { return $parent->$field; } } } return null; } echo getSingleValue('bar'); // my expected value Any ideas why?
  19. figured it out, my bad, it says Invalid mailbox list because the bcc-recipient-field was not populated. I thought it was. Never mind. I'm still wondering though… after all it's prone to fail if ever the server spits out any notice, warning or error. turning of debug mode does not necessarily prevent notices, does it?
  20. I have a module that extends WireData implements Module, ConfigurableModule For the configurations/settings I also have a .config.php file. Now I'd need to add some functionalities for which I think a Repeater field would be the best choice. That field type cannot (according to https://processwire.com/talk/topic/6174-repeater-in-module-config/#comment-228448) or still cannot (?) be used for a configurable module class. I can see though that other modules do use some repeater field on their settings page. How do they do it? Do I need to create a page upon module install that would render all the settings? follow-up question: Once I have the repeater field on the settings page in some way or another, can I reference/list these repeaters inside another field in the system? I know there are page reference fields, the pages to reference would be listed inside a selector field. So can I somehow reference/list the items of the aforementioned repeater field instead?
  21. any news here? I'm also trying to use a repeater field in my ConfigurableModule mymodule.config.php
  22. I'm positive it's well configured, I use WireMailSmtp and AFAIK there's no confusion with IMAP. It used to work just fine but then again, never got to see any debug info since I had it setup as a simple HTML form which redirected right after the email was sent which worked and still works just fine.
  23. The way it looks, again, is that it wasn't an issue with sending, rather interpreting the input on the server. <textarea name="message"><h1>one < two, two > one</h1></textarea> $message = $input->post->textarea('message'); // one < two, two > one <textarea name="message"><h1>one<two, two>one</h1></textarea> $message = $input->post->textarea('message'); // oneone <textarea name="message"><h1>one<two, two>one</h1></textarea> $message = htmlspecialchars($input->post->message, ENT_SUBSTITUTE); // &lt;h1&gt;one&lt;two, two&gt;one&lt;/h1&gt; regarding example 3, in one of my templates, I do $mail = wireMail(); $mail->bodyHTML($message); // <h1>one < two, two > one</h1> the HTML characters get transformed back into < and > in the email, no rich text which is fine. but in another $mail = wireMail(); $mail->body($message); // &lt;h1&gt;one&lt;two, two&gt;one&lt;/h1&gt; So ->bodyHTML() is the better choice, the user is not supposed to add HTML tags anyway but should be able to add < or > However, then the user cannot use breaks \r\n in their input 🤪 How can I have the best of both worlds? never mind this, it's not really related Also, now having a new issue, maybe it's related? https://processwire.com/talk/topic/27813-unknown-invalid-mailbox-list/#comment-228446
  24. I have an issue on the server when sending mails with WireMailSmtp. I get this Notice: Notice: Unknown: Invalid mailbox list: <> (errflg=3) in Unknown on line 0 No idea what that could mean 😞 I know that Notices are not a big deal BUT since I handle my form with AJAX, I need the response to contain nothing more than what I want it to. On the server I populate an array $response with what ever I need on the client, json_encode it and then echo out. So a Notice or a Warning, if not caught, breaks my JSON.parse(response_json); in the frontend. if ($config->ajax) : $subject = $input->post->subject; $fullname = $input->post->first.' '.$input->post->last; $email = $input->post->email; $message = $input->post->message; try { if ($captchaResponse->success == false) { throw new WireException('Captcha abgelaufen'); } $mail = wireMail(); // calling an empty wireMail() returns a wireMail object $mail->to('hostmaster@mydomain.tld', 'hostmaster'); $mail->from = 'hostmaster@mydomain.tld'; $mail->fromName = $fullname; $mail->bcc('dev@mydomain.tld'); $mail->subject($subject); $mail->body($message); $mail->replyto($email); $numSent = $mail->send(); $response['redirectURL'] = $pages->get('/success/')->url; $response_json = json_encode($response); echo $response_json; } catch (WireException $e) { $errormessage = $e->getMessage(); $response['errors'] = $errormessage; $response['redirectURL'] = $pages->get("/error/"); $response_json = json_encode($response); echo $response_json; } endif; in the client: function sendFormData(formData) { var XHR = new XMLHttpRequest(); XHR.onreadystatechange = function () { if (XHR.readyState !== 4) return; if (XHR.status >= 200 && XHR.status < 300) { try { response_obj = JSON.parse(XHR.response); window.location.href = response_obj.redirectURL; } catch(err) { response_obj = JSON.parse(XHR.response); window.location.href = response_obj.redirectURL; } } }; XHR.open('POST', '', true); XHR.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); XHR.send(formData); } Is that a good approach? If not, what's a better solution? Can/should I catch Notices and Warnings somehow? Should I debug this Notice to no happen? Should I not bother and just turn off debug mode?
  25. I think to have read somewhere that fetch doesn't work with every browser. Also, changing everything to use fetch instead of XMLHttpRequest would mean a lot of work, so I'd rather get the latter working… Next, in my setup I use formdata, but I don't just add the entire form to the formdata object but instead set the properties programmatically. So I guess that's why I cannot get it to send the required header along (which it would automatically when just adding the entire form). So that's what I have to work with in order to not have to change everything - use formdata - set formdata values like so formdata.set('foo', bar); (not using a <form></form> tag at all) - assign arrays or json objects to some of the formdata's properties - send formdata via XMLHttpRequest Is that a lot to ask? Anyways, from reading your suggestions, it shouldn't be a problem, all I need to do is #1 set this header in my php code when receiving the data: #2 and since it's an XMLHttpRequest, like you said "it can't hurt", add this header before sending the request: XHR.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); #3 and since most of the send content is json, keep using this on the server: And if I got all of this right, all that was missing was #1 Will try that then.
×
×
  • Create New...