Jump to content

kongondo

PW-Moderators
  • Posts

    7,529
  • Joined

  • Last visited

  • Days Won

    160

Everything posted by kongondo

  1. I am sure your module works just fine but I'll test it anyway ?...doing it right now. Having said that, I am not entirely convinced that your module represents a real world scenario since we have to click on a button to init the SSE.
  2. Not the module itself but the code. If you put that in ready.php, i.e., the hook, serve() and sse() everything hangs. For me, this is also a learning opportunity. It could be that sse is better handled in a module, maybe an autoload one. That it might not work with ready.php. This is one of the things I am trying to establish as well.
  3. Interesting that you mention this. @bernhard, I have been testing in ready.php and that makes everything (all pages backend and frontend on the site) hang even with the break and $i++ present.
  4. This might work (am not sure) but did you want to be more specific by using an ID? You probably know this already but wanted to point out that you can pass all those attrs in one go like this: <?php namespace ProcessWire; $field->attr([ 'hx-post' => $ajaxURL, 'hx-swap' => 'beforebegin', // etc... ]);
  5. This will never work. It should be a URL not a path ?. Either way, ProcessWire will block access to test.php. You have various options for this in the backend, e.g. point it to ProcessModule or a virtual URL that you handle using url hooks or to an Inputfield as shown below: <?php namespace ProcessWire; $adminEditURL = $this->wire('config')->urls->admin . "page/edit/"; $adminEdit = "{$adminEditURL}?id={$this->page->id}&field={$name}"; $out = "<a href='#' hx-get='{$adminEdit}'>"; Which will produce something like this: hx-get="/processwire/page/edit/?id=1234&amp;field=name_of_inputfield"
  6. By this you mean there are no htmx JS errors in the console but htmx does not send an ajax request? Maybe show as an example + the types of inputfields (just in case).
  7. OK. I'll delete the other thread then, unless you want me to merge it here.
  8. Thanks for the info @bernhard. The remaining confusing bit for me is this: Your comment suggests that the break was only for testing ?. What are you using in production? Thanks. I feel like we are still missing something with respect to SSE or it is just the way SSE works. I'd like a situation where, for example, an event would only be pushed to the client after a saveReady fires in ProcessWire. Currently, it looks like SSE is just a glorified long polling, in some respects .
  9. @opalepatrick. What's the difference between this thread and the one you recently marked as solved?
  10. Same here. The while loop is locking up everything. @bernhard, could you please provide more info regarding the endpoint of your url? I.e. ☝️ That url is pointing to some url in ProcessWire. Is it a page URL or a virtual URL that you handle using URL Hooks? Either way could you please show us how you handle requests to that URL in ProcessWire/PHP? I realise you have the thread below as well, but it doesn't show us how you handle 'pings' to your backend either. I am guessing this is where you have your while loop but it would be good to see the whole picture. Thanks.
  11. Great explanation! Thanks.
  12. That's how I got wind of it but on reddit: https://www.reddit.com/r/htmx/ ? 6K+ more views since I posted it here. Some of those are mine ?. I've watched it 5 times already and counting...?
  13. Thanks for sharing. Could you please show us your JavaScript in this case then? For me, it seems the JavaScript is the main issue as it keeps 'polling' as you also noticed. Thanks.
  14. I don't remember the last time I laughed so hard ?.
  15. Thanks for confirming. I noticed the same in this w3schools example and also htmx sse. If you run the w3schools example, even just the JavaScript without the server code, you will notice JS running in a continuous loop, much as you describe above. This has left me more confused about SSE. I thought JS would just initiate first contact with the server then sit and wait for a stream. On a change on the server, JS would respond. So far, I don't see much difference between SSE and Ajax polling. I'll need to read up more about it. Any one got any thoughts on this? @netcarver? Thanks.
  16. Hi @3fingers, Thanks for the example. Could you confirm that this is indeed SSE-driven as opposed to polling? For instance, if you console.log like this: getData(event) { return new Promise((resolve, reject) => { console.log(event.data) if (event.data) { let result = JSON.parse(event.data) // If the incoming page id is different than the current one, hide the container. // if (this.id != result.current.id) { // this.fragmentShow = false // } // This allows the <Transition> vue component to complete its animation before resolving the result. setTimeout(() => { resolve(result) }, 300) } }).then((result) => { this.resolveData(result) }) }, do you see a constant stream (in the console log) or do only see events pushed after you save your ProcessWire page? Thanks.
  17. Hello @maetmar. Welcome to the forums. I have no response to you. I just wanted to point out that I don't think this module is still officially supported. I am not saying it doesn't work; it does. It just won't receive attention from the author, most likely. If you still cannot find an answer to your issue, you might want to consider alternative menu creation modules, such as this -> Menu Builder (I am the author ?).
  18. Where do you store the article during the editing phase? I am assuming an article can be in this phase for more than a day.
  19. https://www.remotion.dev/ https://github.com/remotion-dev/remotion Never heard of this till today. Anyone used it before?
  20. My point was that saveReady will be called everytime you save but added will be called only when you create the page. However, I totally missed the id=0 bit. So, yes, my point itself is somewhat obsolete in this case ?.
  21. Maybe then.. <?php $wire->addHookAfter("Pages::added(template=xyz,id=0)", function($event) { $page = $event->arguments(0); $page->status = 1; // auto-publish }); ? ?
  22. PayPal indempotency and currency issues have been fixed.
  23. Padloper 2 has received a number of updates, pushing it closer to a production release. Stripe Finished the Stripe payment gateway. It is based on the latest Stripe Payment Intents + Stripe Elements. The Stripe Elements widget is fully configurable (UI). I will be updating the docs about this. You can test this now in the demo site. Make sure to read 'about' first here. If upgrading, there are a number of simple steps (actually just one simple step). Just create a page titled Stripe in the admin under the payment gateways parent page. Currently, it is not possible to create a payment gateway using the GUI. Shipping Rate Selection If more than 1 shipping rates are matched, the checkout form will now present the customer with a form to select their preferred rate (e.g. express - €5, standard - €2, etc.). [I have just noticed a bug if using the inbuilt form with this; I'll fix asap]. You can test this by adding this product to the basket and selecting Kenya as the shipping country. Variants The demo site and the starter site have been updated to show how to handle products with variants - adding to basket, checkout, etc. You can test by adding this product or this Padloper [fake] product to the basket. Pay using Stripe and you'll even get to download Padloper! OK, file's fake, obviously. Reports View and functionality is now ready. Powered by htmx. Hoping to create a demo video of this and other backend views soon. Downloads This was not ready in the last release. it is now. Test with 'Padloper' product linked to above. If upgrading, you will need to install the related Fieldtype + add it to the download template. I'll write up about this separately. Bug Fixes Fixed a number of bugs. Docs I've updated the docs in some places. New Requirement I have added a new requirement for PHP BC Math Extension. Currently, Padloper will not work without this. Otherwise we have never-ending pennies/cents rounding errors. Whole libraries have been created just on this one issue; just Google it. BC Math solves it for us. Pending Manual Order Creation: this has been a difficult but getting close to finishing it up. Documentation: Especially the most pertinent. Some minor bug fixes. Some PayPal indempotency + rounding issues! If anyone knows how to pass amounts as pennies/cents to PayPal instead of whole currencies, please let me know. It used to work with the old API. I haven't been able to find how to do this in the latest API and checkout SDK. Production Release My plan is to release a stable version in March 2022. Beta testing has finished. Thank you all who've participated. Edit: making the demo site pretty and perform better on smaller screens is still on my todo. It's not urgent though. Thanks.
  24. Haven't tested this in a modal. One way to do it. <?php namespace ProcessWire; $this->addHookAfter("ProcessPageEdit::buildForm", null, "hookModifyEditFormGUI"); function hookModifyEditFormGUI(HookEvent $event) { if ($event->method == 'buildForm') { $page = $event->process->getPage(); // here you can use $page to skip changes based on a condition // ------------ // get ProcessPageEdit Form $form = $event->return; // not needed just for debugging // $children = $form->children; // get save + keep unpublished button $saveAndKeepUnpublished = $form->children->get("id=submit_save_unpublished"); // if we found it, remove save + keep unpublished if ($saveAndKeepUnpublished) { $form->remove($saveAndKeepUnpublished); } // ------- // get publish button $publish = $form->children->get("id=submit_publish"); // if we found it, change its value if ($publish) { $publish->value = "For Pete's Sake"; } // <<<<<<<<<<<<<<<< // @debug bd($event, __METHOD__ . ': $event at line #' . __LINE__); bd($event->method, __METHOD__ . ': $event->method at line #' . __LINE__); bd($page, __METHOD__ . ': $page at line #' . __LINE__); bd($form, __METHOD__ . ': $form buildForm - at line #' . __LINE__); // bdb($children, __METHOD__ . ': $children buildForm - at line #' . __LINE__); bdb($saveAndKeepUnpublished, __METHOD__ . ': $saveAndKeepUnpublished buildForm - at line #' . __LINE__); bdb($publish, __METHOD__ . ': $publish buildForm - at line #' . __LINE__); // >>>>>>>>>>>>>>>>>> } }
  25. Other options to consider Custom inputfield One of the runtimemarkup modules I'd use htmx with any of the above. Vanilla JavaScript would also work but htmx would give you maximum control over the markup with very minimal effort. With this combo, you could go as fancy as you like (locking edits for some roles, showing preview of colour combos, etc.).
×
×
  • Create New...