Jump to content

monollonom

Members
  • Posts

    275
  • Joined

  • Last visited

  • Days Won

    7

Everything posted by monollonom

  1. I don't know if anyone pm'd you already but it can be quite simple if you only need to generate a static svg from a text input. I found this library https://github.com/kartsims/easysvg which would allow you to do it all server-wise if you have .svg font files at hand. My approach would be to have a file input for the font file, a text input for the text you want to generate the svg from, a textarea (closed by default and non-editable) to hold the svg code, and something like https://processwire.com/modules/inputfield-runtime-only/ to echo the textarea's content (the svg) as a preview. Basically a hook in `ready.php`: require "/path/to/easySVG.php"; wire()->addHookBefore("Pages::saveReady", function(HookEvent $event) { /** @var Page $page */ $page = $event->arguments(0); if($page->template->name !== "font") return; // or whatever if(!$page->fontfile && !$page->text) return; // file and text inputs // copy/pasting from easySVG example $svg = new EasySVG(); $svg->setFontSVG($page->fontfile->url); $svg->setFontSize(100); $svg->setFontColor('#000000'); $svg->setLineHeight(1.2); $svg->setLetterSpacing(.1); $svg->setUseKerning(true); $svg->addText($page->text); list($textWidth, $textHeight) = $svg->textDimensions($page->text); $svg->addAttribute("width", $textWidth."px"); $svg->addAttribute("height", $textHeight."px"); $page->svgcode = $svg->asXML(); // textarea input $event->arguments(0, $page); }); And in your `svgpreview` field/file (check RuntimeOnly doc) or template file: echo $page->getUnformatted("svgcode"); (I used getUnformatted in case there are textformatters but it would best if there's none in the field's settings) It's not tested and made on top of my head but I think this might work. (nice to see Velvetyne here btw, I like your work and a good friend of mine made La Savate ?)
  2. Thanks for the fix. I was almost there it seemed but missed a bit of php knowledge ?
  3. Hi @Robin S, I had an issue and just found a solution, but I can't explain why it's behaving this way: Given the setup mentionned in my previous post, when saving after selecting images it worked fine. But then if I saved the page without changes it cleared my selection. Trying to debug I checked if it was an issue with my image, my loops, had a look at your code but in the end what mattered was the artwork's id used as the option's value. Apparently if the option's key resolved to an int it got cleared ("1" was working though and "0" as well but then no image was shown in the selected part, weird). My solution was to add a prefix (e.g. "id1024") and then it worked as expected. I have to point out this is only happening with the SelectImages inputfield type, if I use AsmSelect, then it works as expected. Do you have an idea why it's behaving this way ? Thanks !
  4. Perfect! And thanks again for your module and these changes / helper
  5. Hi @Robin S, Thank you very much for your modules! With this I managed to create a simple conditional visual page selector. For anyone interested: $wire->addHookAfter('FieldtypeDynamicOptions::getSelectableOptions', function(HookEvent $event) { /** @var Page $page */ $page = $event->arguments(0); /** @var Field $field */ $field = $event->arguments(1); if($field->name === 'artworks') { $artists = $page->artists; // Page-reference field $inputfield = modules("InputfieldImage"); $options = []; foreach($artists as $artist) { foreach($artist->children() as $artwork) { if(!$artwork->gallery->count()) continue; $thumb = $inputfield->getAdminThumb($artwork->gallery->first()); $options[$artwork->id] = [ "label" => "$artwork->title, $artwork->year", "attributes" => [ "data-thumb" => $thumb["thumb"]->url ] ]; } } $event->return = $options; } }); + with the added bonus of being able to customize labels it works great. A question and a suggestion: Based on some condition (eg: if no artist is selected), it'd be nice to be able to display a specific message other than the "Unavailable" label using the hook (for the Dynamic Options module in general) A teeny-tiny css edit: put the clear button at top: 0 and left: 0, and add a padding: 6px to the label <div>
  6. Yeah my thought exactly... though it might be because it's my first time encountering it. My understanding is that it harmonizes with its javascript counterpart (that I never used lol) and it might be good for common cases, but if you want to have something more custom then you either have to write a lot of stuff or use the nice(r) alternative listed above.
  7. Hi, I know quite a few of us are working on multi-language websites and are most likely using the `strftime`, however it's deprecated as of 8.1.0 and set to be removed in 9.0. There's some time left but on my local environment using MAMP and 8.0.8, it's as if it's already gone as dates were not localized anymore. Looking for options, I came accross this which might be useful to others: https://gist.github.com/bohwaz/42fc223031e2b2dd2585aab159a20f30 What's your take on this ? Also I wonder how things will be handled in PW's core as the WireDateTime is using that function as well.
  8. There is an “upgrade” function defined in the Module class you can use (same as “install” / “uninstall”). You don’t need to use a hook for this. https://processwire.com/api/ref/module/ (here’s an example in a module I made)
  9. Perfect it's working as expected, thanks!
  10. Hi @Robin S, Thank you for this useful module. I had a question / suggestion: could it be possible to disable the module on specific repeaters ? In my case there's only one repeater among others that really benefits from the easy sort feature. I know the user could just ignore it and have the relevant repeater with easy mode on by default but maybe it'd be better if the buttons weren't there at all ?
  11. Hi @Sava, I'm not sure I get your question... do you want to know how to get a URL of the QR code to be able to download it ? In the unformatted output the QR code is already in the form of an <img> (or <svg>), but I went ahead and added a "raw" key in the unformatted output. You can download the latest version and try to do something like... $qrcode = $page->getUnformatted("qrcode_field"); foreach($qrcode as $qr) { $filename = $sanitizer->snakeCase($qr["label"]); $label = "Download QR code for \"{$qr["label"]}\""; echo "<a href=\"{$qr["raw"]}\" target=\"_blank\" download=\"$filename\">$label</a>"; } Hope this helps!
  12. I don't know much about the tools you mentioned and regarding your JSON generation issue I'm not sure I see why the modules you mentionned don't fit the bill, but have you also checked/tried: ? Assuming you have templates named "post", "movie", "page",... you could have something like: $wire->addHook("/api/(post|movie|page)/(.*)", function($event) { $template = $this->templates->get($event->arguments(1)); if(!$template) return; header("Content-type: application/json"); $fields = $template->fieldgroup->explode("name", ["key" => "name"]); if($event->arguments(2)) { $page = $this->pages->findOne("template=$template,name=".$event->arguments(2)); if($page->id) { return $page->pageQueryJson($fields); } } return $this->pages->find("template=$template")->pageQueryJson($fields); }); This way you could have pw.domain/api/post returning all posts and then you could query a specific one with pw.domain/api/post/page-name. (one thing to note is the module does not handle repeaters (or other third parties fields) out of the box, though the docs seem to mention how to do so actually it does but I have an issue in my setup, I think) In case this doesn't help or I didn't get your issue, would you mind to elaborate ?
  13. After doing a quick check I assume that was it (multilang issue). Here's a new version that will only output the QR Code in the user's language if it's a guest. Please note you'll still have the two QR Codes if you're logged in. I will think of something to help with the output, something like a ->get() to output a specific source and/or language.
  14. Hi, Sorry about this issue. Do you have multi-language activated on your website ? Also, which field(s) do you show with this qrcode ?
  15. I pushed a new release fixing an issue from the previous update: I forgot to update the name of the inputfield as well when switching from templates to allowedTemplates, resulting in an issue when trying to add/remove templates. You might need to uninstall / reinstall the module, though it shouldn't be an issue to do so.
  16. I published a new update with the following changes: changed filename of css/js files to PageMjmlToHtml (instead of debug) changed module configuration value name templates to allowedTemplates to avoid confusion modified the js so the copy to clipboard code works on all browser modified getCacheName method so it also checks for LanguageSupport and LanguageSupportPageNames Regarding point 2: please double-check the "Templates to convert (...)" field in the module settings properly catched up your previous value Thanks again @wbmnfktr for his thorough tests!
  17. Is it possible outputFormatting is set to false by the module ? If so your repeaters will return everything, including the disabled ones.
  18. Thinking out loud but I'd say there could be a module hooking into pwlink to add select actions in the Lister, something like [select] [>] [lang1] [lang2] [lang3] (or just be part of the core, if possible) Not that easy as there's a mix with dynamic JS stuff... too bad
  19. Fixed! And published! Keep the edge cases coming ?
  20. I just published the new release! In the end I added a condition checking ProcessWire's version and calling the `getPage()` replacement, which uses a new `$pages->request()` method. Let me know if you notice anything else!
  21. The first part with the errors on initial save has been solved but I still need to find an alternative for the second part. In more recent dev versions Ryan removed a function I was relying on in my code (namely ProcessPageView::getPage) and I need to look for an alternative. I'll publish an update once it's all good.
  22. Oof doesn't sound good (thus the alpha state)... I'll have a look, thank you for bringing this up!
  23. Honestly I'm not that familiar with WireHttp, it was just a way for me to have a look at the source code and learn something as well ? Looking again at the code it seems you can get more information about the error by calling print_r($http->error). Maybe it's not the 404 triggering an error in the cURL call but something else ? Again no expert, just trying to help.
  24. When you look at the WireHTTP code you can see that when you're leaving the `use` options to `auto` (and no `fallback`) it will first try to send a cURL request and, should it fail, send another one using socket. In your case that's exactly what's happening since your tests return 404s.
×
×
  • Create New...