Jump to content

monollonom

Members
  • Posts

    159
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by monollonom

  1. I have the same case where I use a start date and an end one. I add a hook that checks the end date when saving the page and if undefined it copies the start date value, this way you can sort using the end date.
  2. If you're on Mac, you can try/buy https://www.araelium.com/screenflick-mac-screen-recorder. I'm just using it for basic screen recording but it seems it could do what you need (except for "append videos" maybe), plus it can be simple enough.
  3. @wbmnfktr I'm not using @bernhard’s tool but you could go this way to have your initial migrate.php: $rm = $modules->get("RockMigrations"); $excludedFields = ["admin_theme", "pass", "permissions", "process", "roles"]; $fieldsCode = []; foreach($fields as $field) { if(in_array($field->name, $excludedFields)) continue; $fieldsCode[] = $rm->getCode($field); } $fieldsCode = "\$rm->migrate(\"fields\" => [\n" . implode(",\n", $fieldsCode) . "\n];"; $excludedTemplates = ["admin", "permission", "role", "user"]; $templatesCode = []; foreach($templates as $template) { if(in_array($template->name, $excludedTemplates)) continue; $templatesCode[] = $rm->getCode($template); } $templatesCode = "\$rm->migrate(\"templates\" => [\n" . implode(",\n", $templatesCode) . "\n];"; And export $fieldsCode and $templatesCode in a file. Regarding the verbosity, it unfortunately boils down to how PW generates the export data. You could be pretty agressive and skip all falsy values but you might get unexpected behaviour.
  4. TagsToFolders Github: https://github.com/eprcstudio/TagsToFolders Modules directory: https://processwire.com/modules/tags-to-folders/ This is a small helper tool to visually organise fields/templates into folders in the menu when they are tagged. This is a simple module that can help you declutter your templates/fields menu by organising them in folders using tags. I initially envisionned this module to be used for cases where fields and/or templates were created by modules and thus not polute the ones created by the user.
  5. I've made yet another update, re: minification part + I came back to adding the debug view right after <body> like I did before, otherwise it did weird stuff to the layout. But this time I made sure my replace also handle cases where the <body> tag has an attribute, to counter the issue you had @wbmnfktr.
  6. Okay so I published the update fixing the issues. And for your case @wbmnfktr I added an option where you can disable the minification if it's messing your layout. By default MJML adds a lot of clutter (whitespaces) in the code and my module is pretty agressive (dumb?) in the way it handles this. So in such case, this option will help out, though you'll get a heavier code (better this way than a non-working one heh). Please let me know if you notice any other issue.
  7. Me making bad assumptions 😬 How about changing these lines to replace "</body>" to "$view/$rawButton</body>" ? It will be safer now that I'm seeing this. (my bad for not seeing the second half of your issues)
  8. Happy new year to you too @wbmnfktr ! I'm sorry you're facing this issue, most likely it's because I'm removing a space before your <strong> tag here PageMjmlToHtml.module line 161. I'm not at home until next week and can't push a fix but you can either just comment this line and the next one or you can edit the lines so the regexes look for a space / \n only after "<" and before ">": Hope this helps !
  9. I noticed an issue with the regexes used for minifying the (working) output. I don't know why it didn't come up before but I just had the bug and fixed it. Still "beta" 😬
  10. Could you share a bit more about your setup ? Is your file input set to receive several files ? I don't really see why you're using glob when you could maybe just use: if(!$page->webfont_archive->count() && !$page->text) return; // we're assuming webfont_archive is set to return a PageFiles and not a single PageFile foreach($page->webfont_archive->find("ext=svg") as $svgFont) { $svg = new EasySVG(); $svg->setFontSVG($svgFont->url); // try ->httpUrl or ->filename if not working /* ... */ } But again it might depend on your setup ?
  11. There is also this module by @Robin S Lots of options to choose from ? (though @bernhard’s might be more suitable as it allows to select only one image)
  12. I pushed a new version with two additions: the first one adds the ability to select specific roles to bypass the cache and thus convert the MJML code on each page render. I don’t think it will be used much but it’s there in case the cache invalidation when saving the page or updating the template’s file is not enough the second one is more interesting as it adds the ability to generate a unique output per GET variable. Previously a GET variable would just output and save to the page’s cache but now you can specify GET variables (or the wildcard "*") to have a cached version per variable. Please note though that, when rendering, if there are several GET variables only the first one is used. `raw` is ignored as it’s used by the module. My current use-case for this is having a "browser" version (with ?browser) where I can display a newsletter with the right webfont. I also added a small note in the settings regarding TracyDebugger to invite module users to disable the panel bar for the MJML templates. TracyDebugger hooks to `render` as well and thus some of its markup might end up in the converted code when showing the `raw` version. I think by now this can be considered "beta", though please test on your local environment first and let me know if you notice anything.
  13. 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 ?)
  14. Thanks for the fix. I was almost there it seemed but missed a bit of php knowledge ?
  15. 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 !
  16. Perfect! And thanks again for your module and these changes / helper
  17. 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>
  18. 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.
  19. 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.
  20. 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)
  21. Perfect it's working as expected, thanks!
  22. 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 ?
  23. 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!
  24. 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 ?
  25. 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.
×
×
  • Create New...