Jump to content

monollonom

Members
  • Posts

    144
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by monollonom

  1. Perfect! And thanks again for your module and these changes / helper
  2. 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 $options = []; foreach($artists as $artist) { foreach($artist->children() as $artwork) { if(!$artwork->gallery->count()) continue; $inputfield = $artwork->getInputfield("gallery"); $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>
  3. 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.
  4. 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.
  5. 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)
  6. Perfect it's working as expected, thanks!
  7. 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 ?
  8. 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!
  9. 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 ?
  10. 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.
  11. Hi, Sorry about this issue. Do you have multi-language activated on your website ? Also, which field(s) do you show with this qrcode ?
  12. 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.
  13. 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!
  14. Is it possible outputFormatting is set to false by the module ? If so your repeaters will return everything, including the disabled ones.
  15. 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
  16. Fixed! And published! Keep the edge cases coming 💥
  17. 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!
  18. 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.
  19. Oof doesn't sound good (thus the alpha state)... I'll have a look, thank you for bringing this up!
  20. 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.
  21. 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.
  22. PageMjmlToHtml Github: https://github.com/romaincazier/PageMjmlToHtml Modules directory: https://processwire.com/modules/page-mjml-to-html/ A module allowing you to write your Processwire template using MJML and get a converted HTML output using MJML API. This is considered to be in alpha and as such needs some testing before being used in production! About Created by Mailjet, MJML is a markup language making it a breeze to create newsletters displayed consistently across all email clients. Write your template using MJML combined with Processwire’s API and this module will automatically convert your code into a working newsletter thanks to their free-to-use Rest API. Prerequisite For this module to work you will need to get an API key and paste it in the module’s configuration. Usage Once your credentials are validated, select the template(s) in which you’re using the MJML syntax, save and go visualize your page(s) to see if everything’s good. You will either get error/warning messages or your email properly formatted and ready-to-go. From there you can copy/paste the raw generated code in an external mailing service or distribute your newsletter using ProMailer. Features The MJML output is cached to avoid repetitive API calls Not cached if there are errors/warnings Cleared if the page is saved Cleared if the template file has been modified A simple (dumb?) code viewer highlights lines with errors/warnings A button is added to quickly copy the raw code of the generated newsletter Not added if the page is rendered outside of a PageView Only visible to users with the page’s edit permission A shortcut is also added under “View” in the edit page to open the raw code in a new tab Multi-languages support Notes The code viewer is only shown to superusers. If there’s an error the page will display: Only its title for guests Its title and a message inviting to contact the administrator for editors If you are using the markup regions output strategy, it might be best to not append files to preserve your MJML markup before calling the MJML API. This option is available in the module’s settings.
  23. Hmm, I think there's a few mistakes here. You should be hooking to InputfieldImage::fileAdded() instead of InputfieldFile::fileAdded() as you wouldn't want to resize files. Also in your first code you're trying to resize every images along with the current one uploaded, I don't think there's a need for that. Your hook could simply be: $this->addHookAfter('InputfieldImage::fileAdded', function(HookEvent $event) { if ($event->object->name === 'image_slider') return; $image = $event->arguments(0); // no need to save the page or the image as it is automatically generated / saved as a variation if($image->width > $image->height) { $image->width(1600, true); // from the doc: a boolean is assumed to be for "upscaling" } else { $image->height(1600, true); } }); And then afterwards you can call your image with: $image = $page->images->first(); $image = $image->width > $image->height ? $image->width(1600) : $image->height(1600); echo $image->url; However seeing how you check for a max-width/height why not just rely on the admin UI, in the image field settings ("Input" tab), to simply set a max size ?
  24. (re: this, I'm no master and just religiously use https://regex101.com/ or stackoverflow in desperate cases)
×
×
  • Create New...