cb2004 Posted August 16, 2022 Share Posted August 16, 2022 What a great module, only just found it after all these years. One for my default toolbox. 1 Link to comment Share on other sites More sharing options...
David Karich Posted April 4, 2023 Share Posted April 4, 2023 Hey @Robin S, thanks for this incredibly useful module. Since PW is now more oriented towards TinyMCE and I am already adapting new projects as well, the question is whether you have plans to port this module for TinyMCE as well? 1 Link to comment Share on other sites More sharing options...
Robin S Posted April 4, 2023 Author Share Posted April 4, 2023 5 hours ago, David Karich said: the question is whether you have plans to port this module for TinyMCE as well? Yes, I do intend to create a new module similar to HannaCodeDialog that supports TinyMCE. But I don't have an estimated date for when it will be ready. For many of my modules, the situation has been that I work on them when I have a need for them myself. And I have quite a number of modules based on CKEditor that I use frequently and that would need to be redeveloped for TinyMCE before I personally can contemplate changing my RTE fields from CKEditor to TinyMCE. So I have quite a lot of work ahead of me and consequently I don't think HannaCodeDialogMCE is going to completed in the very near future. 2 Link to comment Share on other sites More sharing options...
Pete Posted February 9 Share Posted February 9 @Robin S something I had noticed when making all variables editable is even if you don't change them from the defaults, it inserts them into the code. For example, I have a site where I want use this for a mortgage calculator and want to set things like term (years), type (repayment/interest-only), rate (percentage) and so on, but if I only want to change the "type" from repayment (default) to interest only on one page, the hannacode also ends up setting the rate in the code in the editor even though I leave it as the default. This wouldn't normally be a problem but the site has articles for different terms, repayment types and potentially interest rates, but when interest rates change I change the default rate in the Hannacode, but using the dialog it makes it fixed for that page. I think if you use the dialog and the value saved == the default value, it just shouldn't appear in the hanna code block. In my example, this would be the default with no overrides: [[mortgage_calculator]] And some pages I'll want it to default the mortgage amount: [[mortgage_calculator default_amount="70000"]] But changing one variable sets them all using HannacodeDialog even though the other values are the default ones: [[mortgage_calculator default_amount="70000" default_rate="4" default_type="repayment" default_term="25"]] On another note I'm also keen to see a TinyMCE version ??. I know it's a lot harder than this next suggestion, but I did get ChatGPT to write most of a plugin for both TinyMCE and CKEditor in the past year- I knew nothing about plugins for either editor prior to that but with ChatGPT's help I was able to get there in about 90 minutes versus some confusing (to me!) documentation. It was funny because it was ChatGPT creating a plugin to write an article outline USING ChatGPT for one of them ? Link to comment Share on other sites More sharing options...
cb2004 Posted February 9 Share Posted February 9 @Pete TinyMCE version is available but i have discovered a few bugs: 1 Link to comment Share on other sites More sharing options...
Robin S Posted February 9 Author Share Posted February 9 1 hour ago, Pete said: I think if you use the dialog and the value saved == the default value, it just shouldn't appear in the hanna code block. I could probably add an option to support this but I can see it introducing worse issues than it solves. It would make it impossible to save any attribute value where that value has been deliberately set at a value that also happens to be the default. What if the user wants to create a tag where the values should be [[mortgage_calculator default_amount="70000" default_rate="4" default_type="repayment" default_term="25"]]? If all of those attributes get stripped out and you later change the defaults then the tag produces an unintended result. I think the scenario where you have attributes whose default value you intend to later change is a fairly rare one, and in that scenario you'd be better to not configure a default within the Hanna tag but rather use some other means (e.g. inputfield description or notes text in the dialog) to communicate to the user that there's a fallback value that's used when no value is specified and this fallback is subject to change. That way you can distinguish between when a user has chosen a value or not. But if you still want the feature and can live with the side-effects then let me know and I'll look at adding it. 1 Link to comment Share on other sites More sharing options...
Pete Posted February 11 Share Posted February 11 On 2/9/2024 at 9:47 PM, cb2004 said: @Pete TinyMCE version is available but i have discovered a few bugs: Neat, I missed that! @Robin S a very good point and I'm not sure what the solution is to be honest. EDIT: skip to next post. A few options: For some tags the easiest option is not to use the Hanna Code Dialog - maybe we could simply have an option to skip your module being used on a per-tag basis somehow? I've no idea how hard that would be but would solve the problem for this one but still allow it to work for other tags on the same site In the Hanna Code Dialog have the defaults set as placeholders instead of default values - that way if they aren't populated then they aren't used? I can simply set the defaults in the PHP code then. I think perhaps option 2 makes the most sense above - if a dialog option has no value entered simply don't add it into the tag markup. EDIT: @Robin S actually the obvious answer is to use parametername__notes and mention the default there and add the default values into the PHP code I think - I'll try that now. Link to comment Share on other sites More sharing options...
Pete Posted February 11 Share Posted February 11 So I tried this method but it still puts in the parameter if it's empty: I think the solution is to use the notes to convey what the default value will be if empty, but also have a way not to add it into the markup if it's empty - perhaps some sort of __omit_empty override, so default_term__omit_empty parameter since we don't want to make assumptions for everyone else using this already? That way for these specific cases I can also add a note warning them that if it's left empty it will defer to the defaults that can change over time so the content editor has had fair warning. EDIT again - my brain is not in gear today because I can simply do this myself and check for an empty value ? So this is a non-issue now - I can work with this easily by doing: if(strlen($default_term) === 0) { // use the default value in the PHP code } And using strlen because the value might actually be a zero of course. Edit #237: Here's my solution: Attributes: default_amount default_amount__notes=Leave blank to default to 150000 - default may be changed in future default_term default_term__notes=Leave blank to default to 25 years - default may be changed in future default_type default_type__type=select default_type__options=Repayment|Interest Only default_type__notes=Leave blank to default to Repayment default_rate default_rate__notes=Leave blank to default to 4% - default may be changed in future And defaults are now set in the PHP code, overridden with the HannaCode selections if any values are set <?php namespace ProcessWire; $types = ['Repayment' => 'repayment', 'Interest Only' => 'interest']; $default_amount = strlen($default_amount) > 0 ? $default_amount : 150000; $default_term = strlen($default_term) > 0 ? $default_term : 25; $default_type = strlen($default_type) > 0 ? $types[$default_type] : 'repayment'; $default_rate = strlen($default_rate) > 0 ? $default_rate : 4; echo $files->render('partials/calculators/mortgage', ['default_amount' => $default_amount, 'default_term' => $default_term, 'default_type' => $default_type, 'default_rate' => $default_rate]); 1 Link to comment Share on other sites More sharing options...
MarkE Posted July 22 Share Posted July 22 Hi @Robin S. I've been using this successfully for many years but have come across a problem with nested hanna codes. For instance, I have [[link_from_outside link_text="My Group" page_path="?email=[[login_email]]&hash=[[login_hash]]&open=membership"]] When I double click on that, the text box for page_path is blank. If I double click on [[login_email]] or [[login_hash]] then it opens the dialog box for those codes, but it doesn't seem to like them nested in page_path (which works fine if there are no nested codes). Is this fixable or do I just have to live with it and edit it manually (which is a bit awkward as the 'widget' interferes)? PS This image sort-of illustrates the problem with the broken shading: Link to comment Share on other sites More sharing options...
Robin S Posted July 23 Author Share Posted July 23 14 hours ago, MarkE said: For instance, I have [[link_from_outside link_text="My Group" page_path="?email=[[login_email]]&hash=[[login_hash]]&open=membership"]] I've never heard of anyone using nested Hanna tags before and I don't think TextformatterHannaCode itself supports it. I tried it just now without HannaCodeDialog installed and TextformatterHannaCode didn't successfully replace the nested tags. It's too fringe for me to want to spend time on for HannaCodeDialog but seeing as your nested tags don't have any user-editable attributes you can probably use some alternative token replacement for those like wirePopulateStringTags()/WireTextTools::populatePlaceholders(). Or maybe you could play around with manually setting the dialog field value in a HannaCodeDialog::buildForm() hook. Not sure if that would work or not. 1 Link to comment Share on other sites More sharing options...
MarkE Posted July 23 Share Posted July 23 17 hours ago, Robin S said: I tried it just now without HannaCodeDialog installed and TextformatterHannaCode didn't successfully replace the nested tags. Funny that - the code itself is working fine. I'll look into alternatives. Ta. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now