Jump to content

monollonom

Members
  • Posts

    393
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by monollonom

  1. Quick message to say the small tutorial literally saved me just now. I'm going to install the module asap and get back to working. Phew
  2. Also note that strftime has been deprecated in PHP 8.1. Here’s a topic with alternatives:
  3. I guess it depends on the way you structure your templates. In my case I never rely on CKEditor / TinyMCE as a way for the client to structure the page’s content, I actually mostly use them just so they can put links and eventually set in bold or italic. So if I want them to be able to add videos (where I want them to) this is the module I use. To me if you have a video within your template that is on its own (not within a text) then you could definitely use both. Edit: here’s an example within a repeater matrix with image/video types: (french says: "Go full-bleed?" / "Is it an external video?" / "Play automatically?" (I then str_replace the embed code to add the autoplay)) Sorry about this but this is what I meant yes ?
  4. https://github.com/neuerituale/FieldtypeOembed#field-preview I‘m not the author but in my case I use it when users need to be able to add an external video (or audio) to a page and I want to make sure they properly copied the video link. I always have a dedicated field for such videos so I have no use for a TextFormatter that would do something similar in a textarea. Also the field comes with various informations that I use: width/height, poster’s url, ... One other (albeit weird) use I have of this module is to put it as an image’s custom field so that I can replace an image by a video when I have a gallery with both pictures and videos. Though note that in order for this to work you have to allow this Fieldtype in the FieldtypeFile config page and also make a small change in PW core until Ryan accepts my PR. Also there’s no GDPR since it’s up to you to output the iframe’s code (the `html` prop).
  5. Alright, latest version is now published and available through the Upgrade module. Thanks again!
  6. Ah! You uncovered my evil plan to put my website on every newsletter generated from my module ? Joke aside, thanks for spotting this one, it was because of $page->getText returning an empty string when there were no {brackets} in the string. I also spotted another bug if you left the "ignore" textarea empty. Here’s the updated file. Let me know if you notice anything else and otherwise I’ll publish the release! Edit: noticed and fixed another small issue with slashes (if missing in the custom host, or if the relative url doesn’t start with one) It shouldn’t make any difference indeed but thank you anyway for sharing your usage of the module!
  7. Following the previous addition to convert relative URLs into absolute ones I quickly needed to ignore some that weren’t just starting with either "http", "tel" or "mailto" but were also keywords from mailing tools such as "*|UNSUBSCRIBE|*". However I also did some changes in the module’s config, mostly for clarity but also to avoid a call to the MJML API on every save. So before I publish a new release, I wouldn’t mind if any users (@wbmnfktr, @szabesz?) would try it out in a local environment and confirm everything is still working (it is on my side) before I create a new release and update it in the module directory. Thanks!
  8. This is great to read! And I think it’s only fair to think about ways to make it sustainable for you. I’m not 100% sure I would need the Pro version but just for the sake of supporting your great module I wouldn’t mind paying that extra. This is a thing I really (reeeeeally) like with Ryan’s Pro modules model: provide an excellent base and sell this nice extra bit (that can be big) to allow to support the work. Now, I’m close to start working on a client’s website where I will be using your module (of course) and I have some questions: do you happen to have an ETA for this update? will the update process be smooth between the current version and the new one? I assume it will be but I prefer asking. finally: would you recommend to wait to get TinyMCE support? Thanks again for the great work and looking forward for the release.
  9. New very small release fixing a bug introduced in the previous one: it was falsely calling httpUrl on a string when prepending a custom host to relative URLs.
  10. Actually the cached files are cleared if they are expired but only through a LazyCron: (from the ProCache’s page) In other words, if you still have apache running and your database is down, you should not have to worry, so long as your website is fully cached.
  11. Best would be to use ProCache which does exactly this. You just have to select the template you want cached and update your .htaccess so your server serves the generated page’s HTML. Edit: note though that the page needs to be visited for it to be cached
  12. Small FYI: apparently I was wrong... I updated my local setup to 3.0.217 and after refreshing the modules I got a notification inviting me to choose which copy of the duplicate module to use: This was after I confirmed but by default it seemed to have the core one selected. Though there are no problems to report because of this
  13. 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 ?)
  14. Normally copies of core modules inside the site modules’ folder take precedence, so in your case the core TinyMCE module should just be ignored.
  15. 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:
  16. lol entirely forgot I provided the exact same answer... at least I'm consistent ?
  17. Have you tried hooking after your module’s ___upgrade() ? You could also put your code in there like I did for one of mine
  18. 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.
  19. 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.
  20. Issue fixed and module updated! Should be good but let me know if you notice anything else @gornycreative
  21. 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 ?
  22. 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 positive number (int) if a reference has no corresponding footnote (or vice-versa) based on their identifier, both will be ignored and left as is by default references/footnotes are sequenced per field, meaning if you are outputting several fields with this textformatter each footnotes group will start from 1 block elements are not guaranteed to work in footnotes and are thus removed by defaut Options In the module settings you have some options regarding the generated markup: you can change the icon (string) used for the backreference link you can change the classes used for the wrapper, the reference and backreference links you can decide to sequence the footnotes from different fields continuously, instead of restarting from 1 you can edit the list of whitelisted HTML tags that won’t be removed in the footnotes Hook Dynamically change options 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. Group all footnotes in a page Since a textformatter is applied per field, its footnotes are appended right after its content. If you have multiple fields and want to ouput all footnotes in the same place you can use the outputAsArray option: // in init/ready.php $wire->addHookBefore("TextformatterFootnotes::addFootnotes", function(HookEvent $event) { $options = $event->arguments("options"); $options["outputAsArray"] = true; $event->arguments("options", $options); }); $wire->addHookAfter("TextformatterFootnotes::addFootnotes", function(HookEvent $event) { if(empty($event->return["footnotes"])) return; $footnotes = setting("footnotes") ?: []; $footnotes = [ ...$footnotes, ...$event->return["footnotes"] ]; setting("footnotes", $footnotes); }); // in your template file echo $modules->get("TextformatterFootnotes")->generateFootnotesMarkup(setting("footnotes")); Note: if you are using this method to output your footnotes and want to dynamically change the markup/icon, please use the TextformatterFootnotes::generateFootnotesMarkup hook instead of TextformatterFootnotes::addFootnotes
  23. 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... ?)
  24. 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!
×
×
  • Create New...