Jump to content

monollonom

Members
  • Posts

    338
  • Joined

  • Last visited

  • Days Won

    8

Everything posted by monollonom

  1. It wouldn’t be too difficult using ProcessWireUpgradeCheck::getModuleVersions. You can also have a look at ProcessWireUpgradeCheck::loginHook to see how it's used. Something like: $wire->addHook("LazyCron::everyMonth", function(HookEvent $event) { $checker = $event->modules->get("ProcessWireUpgradeCheck"); if(!$checker) return; $upgrades = $checker->getModulesVersions(true); // we only want modules with new versions if(!count($upgrades)) return; $subject = "There are " . count($upgrades) . " modules to update on $config->httpHost"; $body = "Hi!\n\nAn upgrade is available for these modules on $config->httpHost:\n\n"; foreach($upgrades as $name => $info) { $body .= "- $name ($info[remote])\n"; } $body .= "\nHead to " . $event->pages->get("process=ProcessWireUpgrades")->url . " to upgrade"; // not sure if this `get` would work? $mail = new wireMail(); $mail->from("upgrade@$config->httpHost") ->to("you@mail.com") ->subject($subject) ->body($body) ->send(); }); (non tested code written from my phone, so please forgive the formatting and/or mistakes ?)
  2. Normally copies of core modules inside the site modules’ folder take precedence, so in your case the core TinyMCE module should just be ignored.
  3. Haven't used it yet but I think this is something you can control in the module’s (or even in the field’s?) settings with the pastefilter whitelist:
  4. lol entirely forgot I provided the exact same answer... at least I'm consistent ?
  5. Have you tried hooking after your module’s ___upgrade() ? You could also put your code in there like I did for one of mine
  6. I'm only dealing with video, but this is the latest I used: <?php // greatest common divisor function gcd($a, $b) { return $b ? gcd($b, $a % $b) : $a; } $padding = $video->height / $video->width * 100; $padding = str_replace(",", ".", $padding); // css doesn’t like commas $ratio = gcd($video->width, $video->height); $ratio = $video->width / $ratio . " / " . $video->height / $ratio; echo "<div class='video' style='aspect-ratio:$ratio; padding-top:$padding%;'>$video->html</div>"; CSS: .video { aspect-ratio: 16 / 9; width: auto; max-width: 100%; height: auto; max-height: 100%; padding-top: 56.25%; } .video > iframe { display: block; width: 100%; height: 100%; position: absolute; left: 0; top: 0; } /* if aspect-ratio is supported */ @supports (aspect-ratio: 16/9) { .video { padding-top: 0 !important; } .video > iframe { position: static; } } Constraining things in the y-axis has always been one of my biggest pain in CSS... but aspect-ratio goes in the right direction in that you can just go ahead and set the max-width/height to 100% and it will adapt nicely within its parent Wait actually some testing goes against what I just wrote, I have to test further ? It does work but as always with CSS there will be weird edge cases. I wasn't using it much before but now the support is quite reasonnable.
  7. I just pushed a new release adding a new option I needed: the ability to automatically convert relative urls into absolute ones. You can also choose the host to prepend or any query parameters to append. More infos in the settings.
  8. Issue fixed and module updated! Should be good but let me know if you notice anything else @gornycreative
  9. 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 ?
  10. 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.
  11. 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... ?)
  12. 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!
  13. 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") { // ... }
  14. 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);
  15. 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".
  16. @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);
  17. 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?
  18. Hi @adrian, would you consider adding your fork in the module directory so we can update it using ProcessWireUpgrade? That would be great!
  19. 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.
  20. 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.
  21. @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.
  22. 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.
  23. 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.
×
×
  • Create New...