Jump to content

bernhard

Members
  • Posts

    6,671
  • Joined

  • Last visited

  • Days Won

    366

Everything posted by bernhard

  1. Have you tested my module?
  2. The main difference is how migrations are triggered. On the old module I've used the "fireOnRefresh" approach which fired migrations on every modules refresh. On the new version you can add files to a watchlist and migrations will automatically fire if a file changed. That makes a huge difference when working with the module as you'll only need a page reload and the new data will be there ? Also I've improved logging so that it's easier to see what happens and the module handles same cases in the same way (the old one sometimes threw exceptions, sometimes did early exists). Other than that it's quite the same as the old one as I'm really happy with how everything worked there. I've refactored all methods while transferring them from the old version to the new one.
  3. May I ask why you want to save HTML code? The screenshot looks like it would be a perfect fit for a CKEditor field...
  4. So what about the error you previously posted?
  5. Nice writeup, congratulations ?
  6. Thx Ryan for pulling my changes and improving them ? I wonder if you have any numbers of how much more efficient it is to use a non-hookable method compared to using a hookable method? I'm usually not thinking too much about this as everything seems to be fast anyhow. But as you have refactored that approach it might be a noticable difference? I'd be very happy about some insights ?
  7. Hey @Richard Jedlička thx for the really helpful module ? Would it be possible to add icons to fields that have no label? Eg a checkbox. Ideally the icon would appear in the top right corner:
  8. https://github.com/baumrock/RockSSE-demo Would be great if many of you could test this on your setups and let me know if it works as expected! In production I have a long running task like trashing lots of pages. The script will finish when all pages have been trashed.
  9. It's an URL hook with the code I already posted above: Ok I'm missing an $i++ in the example! So it will run forever... Simply add an $i++ in the loop or do while(++$i) ...
  10. You might have a process running then in the background... this is why I added the manual break ($i>30) in my example... This is how a correct SSE implementation looks like: one single request stream of +4s message appear in "EventStream" tab console shows logs (because I'm doing console.log in JS)
  11. No, the issue is not the JS, the issue is that the data received is not properly formatted, so the client thinks the request failed and it fires a new request which is the same as if it were ajax polling. If the received data is properly formatted the stream can be read and the connection keeps open. This is my JS: const evtSource = new EventSource(url, { withCredentials: true } ); evtSource.onmessage = function(event) { console.log(event); if(event.data==='DONE') { evtSource.close(); if(modal) modal.hide(); if($button.data('reload')) RockGrid2.getGrid($button).reload(); } else if($progress) { $progress.fadeIn(); $progress.html(event.data); } }
  12. Yep, RockToken can help here ? https://github.com/baumrock/RockToken
  13. I've had the same problem - the script seemed to work but sent several requests just like ajax polling: But I've managed to get it working correctly and the result is a nice stream of data and updating feedback for the user while bulk-editing of data in RockGrid. There's no reload, no ajax-polling: The key is to echo the correct message. I've built a method for this in my module: /** * Send SSE message to client * @return void */ public function sse($msg) { echo "data: $msg\n\n"; echo str_pad('',8186)."\n"; flush(); } If you do that, you can do something like this: <?php header("Cache-Control: no-cache"); header("Content-Type: text/event-stream"); $i = 0; while(true) { $this->sse("value of i = $i"); if($i>30) return; // manual break after 30s for testing while(ob_get_level() > 0) ob_end_flush(); if(connection_aborted()) break; sleep(1); } Not sure if the ob_get_level and ob_end_flush are necessary...
  14. Yes, you can use InputfieldTextTags https://processwire.com/blog/posts/pw-3.0.177/ But it would be a lot easier to use HannaCode or a custom Textformatter module which replaces [file=foo-bar.php] with the content of the file foo-bar.php
  15. $item is a Page object. The "Page" class extends the "Wire" class (which all of PW's classes do), so you can access the ProcessWire instance via $item->wire and from there you can access the "Sanitizer" class via ->sanitizer: $item->wire->sanitzer->trunc(...) <?php $list = $pages->get(1234)->children; $toJSON = $list->explode(function($item) { $summary = $item->wire->sanitizer->truncate($item->summary, [ 'type' => 'punctuation', 'maxLength' => 155, 'visible' => true, 'more' => '…', ]); return [ 'title' => $item->title, 'id' => $item->id, 'start' => $summary, ]; }); Most of the time you can even do $item->sanitizer without the ->wire but I'd consider it a best practise to use ->wire because it's slightly more efficient and less error prone.
  16. I've created a PR for this issue https://github.com/processwire/processwire/pull/219
  17. Very interesting!! Thx for sharing. https://www.githubunwrapped.com/ is built with it ?
  18. @kongondo I don't understand. Is added anything better than saveReady? Wouldn't you have to do a save() or setAndSave() in your example? And isn't the id=0 obsolete (or even wrong) if you are using the added hook?
  19. Alternatively to hiding/renaming the publish button you can auto-publish the page when it is created: <?php $wire->addHookAfter("Pages::saveReady(template=xyz,id=0)", function($event) { $page = $event->arguments(0); $page->status = 1; // auto-publish });
  20. Thx teppo, I'm not sure if it was me. I never got any further than testing WireFrame. I think I don't have it in any of my projects so it's out of my head and you can ignore my request if there is still something left ?
  21. If you do some testing note that it's really easy to add custom markup to any inputfield via hook: <?php $wire->addHookBefore("Inputfield(className=InputfieldCKEditor)::render", function($event) { $field = $event->object; $id = $field->id; $field->appendMarkup = "<script> \$li = $('#wrap_$id'); console.log(\$li); </script>"; }); Looking forward to your results ?
  22. I still don't get what you are looking for. I thought I understand your need: Making the process more standardized and easier for non-devs meaning more click click instead of writing code. That's what I tried to solve with my proof of concept module. But you said "that looks great" in your first post and then turned around and it does not seem to be what you are wanting... Eh nothing, all is ready, we have even more with JWT implementation. It's just missing a function which return the pages tree. Something like less than 10 lines of code. This question was targeted to @wbmnfktr to better understand him. When we where talking about easy json feed the very first time my answer was: Url hook + findRaw + json_encode... ( https://processwire.com/talk/topic/19112-module-page-query-boss/?do=findComment&comment=221874 ) I don't agree on this one. I have not tried the module (because I have not had the need), but it looks complicated to me. Something that definitely would take longer than 2 min even just to understand how to set it up. That's why I built my module - super simple to setup, no code necessary. But it is still not what @wbmnfktr is looking for, so I'm confused and it feels like we are going in circles...
  23. You can increase the number of "rows" in the field's settings (input tab). Is that what you are looking for?
×
×
  • Create New...