Jump to content

monollonom

Members
  • Posts

    328
  • Joined

  • Last visited

  • Days Won

    8

Everything posted by monollonom

  1. Is it really necessary to introduce a third-party dependency to do a comparison and updates the parts that were updated? Since the whole process won't be instant, couldn't it just be a matter of reloading an iframe showing the page? (which is what you're doing already with ProDrafts I assume) I feel you could (should?) come up with your own minimal implementation of SSE to signal an autosave to a "preview" tab and have the js simply reload the iframe. Reading the Mozilla page I guess you could have two EventSource : one signaling a global autosave for PW's "preview" tab to automatically reload and another one signaling specific changes (in JSON format?) that developers could eventually listen to on their own using htmx or what, which is what you're actually suggesting with ?change=body, my bad. I hope I'm not saying obvious things or misunderstanding what's been said, sorry if I did. A question though re the autosave feature: since this is partly meant as a way to preview changes on a page, what happens if one wants to roll back to the initial state of the page ? Could you provide a way of cancelling all of the auto-saved changes ? Actually now that I think of it and re-reading your post, how would you do if you have a published page that you want to edit but don't want the edits to be seen by a guest ?
  2. Okay so I boiled it down to this: Apparently there's no need to have markupValue() return anything else other than $value as it most likely calls wakeupValue() in any case. Also I went ahead and removed the part hooking into the render() function of the InputfieldMarkup. This removed the double call on the back-end while keeping the front-end call working. Thanks again, I'm pushing the update right now!
  3. Hi @adrian, Glad the module is of help and thank you for the feedback! I applied your suggested changes and at first got an empty output on the front-end. However, taking some cues from @Robin S's FieldtypeRuntimeOnly, I managed to apply the necessary changes for it to work properly. And as a nice side effect the ___getQRText hook now has access to the current $page! Thanks again.
  4. Hi, Thank you for your module. Just a suggestion : because I don't have a specific "description" field for the meta tag, I rely on an "about" field which is a CKEditor. Because of a <a> tag within it, there was an issue rendering one of the pages. So on my local copy I used $sanitizer->truncate() on line 134: $this->description = $this->description ?? $this->sanitizer->truncate($this->page->get($this->description_selector), 160, ['type' => 'sentence']); Maybe this could be a valuable addition ?
  5. Thank you for your detailed answer, I'll have a look and come back with the solution (or questions) I'll come up with !
  6. I just started using it on the client project I mentionned a while ago and it's working amazingly, thank you so much for your hard work ! I have one suggestion / request though: could there be a way to add a string at the end of the translation automatically ? Something like "(translated with DeepL)". Ideally as an option per text field ? I'm seeing from the source code that ___executeData() is hookable, would you suggest to go this way ? Editing the returned json ? Thank you in advance for your feedback / help.
  7. I thought my download link in the modules directory was working but apparently it didn't. Maybe because I forgot to create a release ? Anyway the download link should be working fine now.
  8. I made a small update where you can now output the QR Code on the front-end by calling the field directly (instead of rendering the inputfield) and I added the option to output the image in either .svg or .gif (if .svg, you'll have the additional ability to output the markup directly, instead of a base64).
  9. (once again I was surprised to see a work of mine pop up in the newsletter, this time without even listing the module on PW modules website ?. Thx @teppo !) FieldtypeQRCode Github: https://github.com/eprcstudio/FieldtypeQRCode Modules directory: https://processwire.com/modules/fieldtype-qrcode/ A simple fieldtype generating a QR Code from the public URL of the page, and more. Using the PHP library QR Code Generator by Kazuhiko Arase. Options In the field’s Details tab you can change between .gif or .svg formats. If you select .svg you will have the option to directly output the markup instead of a base64 image. SVG is the default. You can also change what is used to generate the QR code and even have several sources. The accepted sources (separated by a comma) are: httpUrl, editUrl, or the name of any text/URL/file/image field. If LanguageSupport is installed the compatible sources (httpUrl, text field, ...) will return as many QR codes as there are languages. Note however that when outputting on the front-end, only the languages visible to the user will be generated. Formatting Unformatted value When using $page->getUnformatted("qrcode_field") it returns an array with the following structure: [ [ "label" => string, // label used in the admin "qr" => string, // the qrcode image "raw" => string, // the raw qrcode image (in base64, except if svg+markup) "source" => string, // the source, as defined in the configuration "text" => string // and the text used to generate the qrcode ], ... ] Formatted value The formatted value is an <img>/<svg> (or several right next to each other). There is no other markup. Should you need the same markup as in the admin you could use: $field = $fields->get("qrcode_field"); $field->type->markupValue($page, $field, $page->getUnformatted("qrcode_field")); But it’s a bit cumbersome, plus you need to import the FieldtypeQRCode's css/js. Best is to make your own markup using the unformatted value. Static QR code generator You can call FieldtypeQRCode::generateQRCode to generate any QR code you want. Its arguments are: string $text bool $svg Generate the QR code as svg instead of gif ? (default=true) bool $markup If svg, output its markup instead of a base64 ? (default=false) Hooks Please have a look at the source code for more details about the hookable functions. Examples $wire->addHookAfter("FieldtypeQRCode::getQRText", function($event) { $page = $event->arguments("page"); $event->return = $page->title; // or could be: $event->return = "Your custom text"; }) $wire->addHookAfter("FieldtypeQRCode::generateQRCodes", function($event) { $qrcodes = $event->return; // keep everything except the QR codes generated from editUrl foreach($qrcodes as $key => &$qrcode) { if($qrcode["source"] === "editUrl") { unset($qrcodes[$key]); } } unset($qrcode); $event->return = $qrcodes; })
  10. I'm on MacOS using Firefox. I know Firefox has its way of doing when it comes to some cases with margin-bottom... Regarding colors: maybe a suggestion would be to set the blue for buttons / nav bar to a be a bit more blue-ish. Here I took the color from the (invisible) background of thumbnails (32, 115, 206) : Edit: wouldn't mind as well to have the left and right paddings to match the ones on the header (40px left/right). And sorry for throwing you css details !
  11. Tiny detail but the margin-bottom on the footer creates a white space I was surprised at first seeing the new colors but it looks good !
  12. In the end it seems to work if I specifically save the Page Reference field: $home->save("events"); I'm still not sure though why saving the page from a guest session would break the link between images and their field...
  13. After some more testing, it looks like it's not because of the hook or the LazyCron but because of the code being executed by a guest. Edit: it's actually just the fact that I save the homepage (from a guest session) that makes the images disappear. I have access control toggled on for the homepage template but I thought API calls would be respected, am I wrong ?
  14. Yes at first I did set the output formatting to "false" but wanted to try and see how it goes without it, with no luck. I'll edit my post though, thanks. (also for completeness, I'll try again with of(false) just to be 100% sure)
  15. (I edited the title to reflect my findings down below, I'm leaving the original post as is though) Hi, This is the first time I'm using LazyCron so maybe I did something wrong but basically when the hook function is triggered and does its thing to the homepage, all images within that page disappear from the database, while remaining in the file system. When I try to re-upload the same image it tells me "Refused file X because it is already on the file system and owned by a different field" (couldn't find that other field though). Has anybody encountered something like this before ? Here is my hook, from ready.php: $wire->addHook("LazyCron::everyHour", function() { $home = wire("pages")->get(1); $home->of(false); $nextMonth = strtotime("next month"); $newEvents = wire("pages")->find("template=event, end_date>=today, start_date<$nextMonth, limit=10, sort=start_date, sort=end_date, sort=title"); foreach($home->events as $event) { if (!$newEvents->has($event)) { $home->events->remove($event); } } foreach($newEvents as $new) { if (!$home->events->has($new)) { $home->events->add($new); } } $home->save(); }); $home->events is a Page Reference field. The idea is to update the field with the ten closest events and allow the editor to sort them in the admin. Thank you !
  16. Hi Ryan, as part of your rewritting of the WireDatabasePDO class, did you get a chance to have a look at this issue ?
  17. I've never worked with custom page classes but I assume you could add a hook on the "loaded" event of your custom page and execute your custom function, something like : $wire->addHookAfter("CustomPage::loaded", function($event) { $page = $event->object; $page->yourCustomPageFunction(); });
  18. Have you tried with Pages::added ?
  19. Great to read ! About your other request, I had a look at the code and there doesn't seem to be a hook available for what you're looking for (the closest being this non-hookable function). Maybe someone else can come up with another solution.
  20. I had a different setup where I wanted my files served from a sub-domain (even though in the end it was from /site/assets/files), but it's somehow related. What I did was to point the sub-domain to /site/assets/files, and then add this hook in ready.php : $wire->addHookAfter("Pagefile::url", function($event) { static $n = 0; if(++$n === 1) { $file = $event->object; $url = $file->httpUrl; $host = wire("config")->httpHost; $url = str_replace("$host/site/assets/files", "sub.domain.com", $url); $event->return = $url; } $n--; }); You could replace "sub.domain.com" to "domainB.com/site/assets/files" (or even clear the "site/assets/files" part in your case). Hope it helps !
  21. Are these website all on the same server ? Or on shared hosting ? Or do you also have the issue locally ? I have this issue with one of my websites where sometimes the TTBF drops down. Can't say for sure as I did not investigate much yet but I assume it's because there might be other websites on the shared hosting taking too much power. Sorry I'm not helping much so here's a screen of the timings I had for your website, looks pretty normal to me :
  22. If everything seems to point to emails being sent successfully but not received, shouldn't you have a look if the emails go to spam or are refused by the receiving address ? You can try this for example https://www.mail-tester.com/?lang=en
  23. Would showing the path instead of the title be okay ? I thought of a hook first but you could do the trick with a bit of CSS ul.pw-dropdown-menu-shorter li.ui-menu-item a::before { content: attr(title); margin-right: 3px; } ul.pw-dropdown-menu-shorter li.ui-menu-item a span { display: none; } (hopefully it doesn't target anything else, but from my quick testing it looks ok !) Before: After:
  24. Isn't your code missing a bit for $roles ? Right now, and if not, you could just do echo $page->insight_author("<a href='{url}'>{title}</a>, {staff_role}");
  25. Not sure if this is what you're looking for (or if you already know about it) but explaining the focus feature to your editors might come handy for you when generating variations for srcset. If cropped, the image returned will respect the focus point and try to keep it centered.
×
×
  • Create New...