Jump to content

monollonom

Members
  • Posts

    275
  • Joined

  • Last visited

  • Days Won

    7

Everything posted by monollonom

  1. Issue fixed and module updated! Should be good but let me know if you notice anything else @gornycreative
  2. Quick question regarding your usage: were you calling the function on its own? Or was it through the textformatter applied to a text field? What I could do is check if $options is not an array and in this case assume it's $field, but the $field argument is not used within the function as it's just there so you can do field-specific stuff using the hook. Edit: oh wait I just saw my mistake... on line 44 😵
  3. TextformatterFootnotes Github: https://github.com/eprcstudio/TextformatterFootnotes Modules directory: https://processwire.com/modules/textformatter-footnotes/ This textformatter adds footnotes using Markdown Extra’s syntax, minus Markdown About This textformatter was primarly created to ease the addition of footnotes within HTML textareas (CKEditor or TinyMCE) using Markdown Extra’s syntax. It will also retain any inline formatting tags that are whitelisted. Usage To create a footnote reference, add a caret and an identifier inside brackets ([^1]). Then add the footnote in its own line using another caret and number inside brackets with a colon and text ([^1]: My footnote.). It will be put automatically inside the footnotes block at the end of the text. Notes: the identifier has to be a number but it is permissive in that you can put in the wrong order and it will be numbered back sequentially there is no support for indentation, though since <br> tags are allowed you should be fine if a footnote has no corresponding reference, it will be ignored and left as is Options In the module settings, you can change the icon (string) used as the backreference link but also the classes used for the wrapper, the reference and backreference links. You can also edit the list of whitelisted HTML tags that won’t be removed in the footnotes. Hook If you want to have a more granular control over the footnotes (e.g. per field), you can use this hook: $wire->addHookBefore("TextformatterFootnotes::addFootnotes", function(HookEvent $event) { $str = $event->arguments(0); $options = $event->arguments(1); $field = $event->arguments(2); if($field != "your-field-name") return; // Say you want to change the icon for a <svg> $options["icon"] = file_get_contents("{$event->config->paths->templates}assets/icons/up.svg"); // Or change the wrapper’s class $options["wrapperClass"] = "my-own-wrapper-class"; // Put back the updated options array $event->arguments(1, $options); }); Check the source code for more options.
  4. Seems like you could also hook into WireFileTools::include, which is used behind $files->include or $files->render, maybe you could do the same check / filename replacement there. (as per my edit in the previous message I managed to not only miss an important point but also the fact you already had a similar code... 🙄)
  5. Ah, somehow I missed the part where you said you needed to fallback should the file not be there, my bad! Edit: I even missed the fact you already had a similar code 😑 From what I'm reading in PW’s source code, you could hook before TemplateFile::render (...time passing doing tests...) I think the best is to check if the dev’s file exists and then use setFilename() in init.php: wire()->addHookBefore("TemplateFile::render", function(HookEvent $event) { /** @var TemplateFile $tpl */ $tpl = $event->object; $userTpl = str_replace("templates/", "templates-dev/" . $event->user->name, $tpl->filename); if(file_exists($userTpl)) { $tpl->setFilename($userTpl); } }); Try and let me know if it works for you!
  6. I actually share a similar setup but for another use (templates-dev is for local development / preview) and in my case I use this in my config.php: $config->urls->templates = $config->urls->site . "templates-dev/"; $config->paths->templates = $config->paths->site . "templates-dev/"; $config->urls->fieldTemplates = $config->urls->site . "templates-dev/fields/"; $config->paths->fieldTemplates = $config->paths->site . "templates-dev/fields/"; Similar to what @androbey suggested. However I don’t switch based on the user but it's easy to do so in your site/init.php if($user->name === "username") { // ... } elseif($user->name === "admin") { // ... }
  7. In this case, best is to simply go with either an "if" or "switch" statement, something like: $datum = $concert->date; $format = "E, d. LLLL yyyy, HH:mm"; switch($user->language->name) { case "deutsch": $lang = "de-DE"; $format = "EE dd.MM.YYYY"; break; case "français": $lang = "fr_FR"; break; case "default": $lang = "en_US"; break; } $fmt = new \IntlDateFormatter($lang, \IntlDateFormatter::FULL); $fmt->setPattern($format); echo $fmt->format($datum);
  8. You mean the multi-lang site profile? I assume your default language is English then, did you try the code I gave you? The important part is replacing new \IntlDateFormatter('DE', with: new \IntlDateFormatter($user->language->isDefault() ? "en_US" : "de-DE" And if it happens to be the wrong way around, just invert "en" and "de".
  9. @Thomas -Allwinds Webstudio when creating your IntlDateFormatter, do you set the locale based on the user’s language or is hard-coded like in your code sample? It depends on how you named your languages or which one is your default but maybe it could be: $datum = $concert->date; $fmt = new \IntlDateFormatter($user->language->isDefault() ? "en_US" : "de-DE", \IntlDateFormatter::FULL ); $fmt->setPattern('E, d. LLLL yyyy, HH:mm'); echo $fmt->format($datum);
  10. I just came across this issue and the solution is pretty simple: replace strftime() with date("YmdHMS", $seconds) I don't really understand the use of strftime() here since there's no use of language-dependent strings... @horst Could you have a look at this or would you rather accept a PR?
  11. Hi @adrian, would you consider adding your fork in the module directory so we can update it using ProcessWireUpgrade? That would be great!
  12. 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.
  13. 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.
  14. @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.
  15. 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.
  16. 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.
  17. 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.
  18. 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)
  19. 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 !
  20. 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" 😬
  21. 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 ?
  22. 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)
  23. 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.
×
×
  • Create New...