Robin S Posted April 29, 2019 Author Posted April 29, 2019 @MilenKo, it's not possible to have a required field in the dialog because the dialog form is not submitted anywhere for ProcessWire validation - the field values are just captured via Javascript when the dialog is closed. You should check for empty field values in the code for your Hanna tag. Incidentally, this is true for any "required" field anywhere in PW because nothing is ever really required - the user can simply abandon the edit process if they want and leave unfilled required fields, so you always need to check that fields are actually populated before doing anything with their value. 1
MilenKo Posted April 29, 2019 Posted April 29, 2019 @Robin S Thanks for your clarification. I was afraid you would say so, but was just thinking if it would be possible for me to modify the dialogue files and have an extra option added like the other attribute options - something like: attribute__options=Option1|Option2 but with some extra logic: attribute__requirements=required or similar. My idea is that from the dropdown menu, the user is provided a choice of multiple blocks and once one is selected, the dialogue opens up and can intercept an eventual requirement set thorugh the module. Once the user has finished and press OK, if he double clicks on the HC he is still seeing the same code so technically it would be difficult for the user to change the text etc. and is presented a nice "reminder" of an empty attribute or else. On the other thought, the present functionality might be a better option for me as I am allowing a user to choose a news tab category (1 out of 10) so he can leave 1 empty, 2 empty and then add 3, 4 etc. Will see how it would be completted to fit the requirements and avoid any errors as presently I am grouping all the attributes to an array, then have to clean the empty values, then to reorder and then to apply it. But hey, it works and it was super easy for my 8 years old boy I've tested with to add the block, pick categories, limit the number of pages shown etc. GREAT THANK YOU FOR THE EFFORTS AND MODULE! 1
MilenKo Posted April 30, 2019 Posted April 30, 2019 Btw, is it possible to set the width/height of the dialogue box (width/height) as presently I have about 10 drop-down boxes for categories plus some other limiters to show a specific page count on the block so the scrolling is not very convenient? Maybe I can make the dialogue wider through some options or else? I mean if it is possible to have the options per tag, not by default?
Robin S Posted May 1, 2019 Author Posted May 1, 2019 16 hours ago, MilenKo said: I mean if it is possible to have the options per tag, not by default? No, that isn't possible in this module - the dialog width and height in the module config applies globally to all Hanna tags.
MilenKo Posted May 2, 2019 Posted May 2, 2019 @Robin S Thank you for your info. Would it be possible to have an option to set the width and height of the dialogue for all Hanna Tags which would make my options visible better or I would have to set the dimensions by editing the module files?
Robin S Posted May 2, 2019 Author Posted May 2, 2019 8 minutes ago, MilenKo said: Would it be possible to have an option to set the width and height of the dialogue for all Hanna Tags which would make my options visible better or I would have to set the dimensions by editing the module files? As per my previous reply and the module readme there are config options for dialog width and height. Or maybe I don't understand your question. 1 1
MilenKo Posted May 2, 2019 Posted May 2, 2019 Oh, @Robin S my bad. I don't know how but I've missed to check the module configuration page and was looking at the tag options again. It works perfectly now and I can increase the size from there as most of my tags would require bigger window. Thank you again for the help. 1
Robin S Posted June 1, 2019 Author Posted June 1, 2019 (edited) v0.2.1 released. This is a fairly major update in that there has been quite a bit of refactoring. Please be alert for and report any issues. ProcessWire >= v3.0.0 is now required. This release adds a new hookable HannaCodeDialog::buildForm() method that lets you build the dialog form in the hook rather than setting inputfield options as pseudo-attributes in the Hanna Code tag settings. From the readme... Build entire dialog form in a hook You can hook after HannaCodeDialog::buildForm to add inputfields to the dialog form. You can define options for the inputfields when you add them. Using a hook like this can be useful if you prefer to configure inputfield type/options/descriptions/notes in your IDE rather than as extra attributes in the Hanna tag settings. It's also useful if you want to use inputfield settings such as showIf. When you add the inputfields you must set both the name and the id of the inputfield to match the attribute name. You only need to set an inputfield value in the hook if you want to force the value - otherwise the current values from the tag are automatically applied. To use this hook you only have to define the essential attributes (the "fields" for the tag) in the Hanna Code settings and then all the other inputfield settings can be set in the hook. Example buildForm() hook The Hanna Code attributes defined for tag "meal" (a default value is defined for "vegetables"): vegetables=Carrot meat cooking_style comments The hook code in /site/ready.php: $wire->addHookAfter('HannaCodeDialog::buildForm', function(HookEvent $event) { // The Hanna tag that is being opened in the dialog $tag_name = $event->arguments(0); // Other arguments if you need them /* @var Page $edited_page */ $edited_page = $event->arguments(1); // The page open in Page Edit $current_attributes = $event->arguments(2); // The current attribute values $default_attributes = $event->arguments(3); // The default attribute values // The form rendered in the dialog /* @var InputfieldForm $form */ $form = $event->return; if($tag_name === 'meal') { $modules = $event->wire('modules'); /* @var InputfieldCheckboxes $f */ $f = $modules->InputfieldCheckboxes; $f->name = 'vegetables'; // Set name to match attribute $f->id = 'vegetables'; // Set id to match attribute $f->label = 'Vegetables'; $f->description = 'Please select some vegetables.'; $f->notes = "If you don't eat your vegetables you can't have any pudding."; $f->addOptions(['Carrot', 'Cabbage', 'Celery'], false); $form->add($f); /* @var InputfieldRadios $f */ $f = $modules->InputfieldRadios; $f->name = 'meat'; $f->id = 'meat'; $f->label = 'Meat'; $f->addOptions(['Pork', 'Beef', 'Chicken', 'Lamb'], false); $form->add($f); /* @var InputfieldSelect $f */ $f = $modules->InputfieldSelect; $f->name = 'cooking_style'; $f->id = 'cooking_style'; $f->label = 'How would you like it cooked?'; $f->addOptions(['Fried', 'Boiled', 'Baked'], false); $form->add($f); /* @var InputfieldText $f */ $f = $modules->InputfieldText; $f->name = 'comments'; $f->id = 'comments'; $f->label = 'Comments for the chef'; $f->showIf = 'cooking_style=Fried'; $form->add($f); } }); Edited June 1, 2019 by Robin S Updated version number 8
BigRed Posted October 16, 2019 Posted October 16, 2019 I have HannaCode that generates a message box. The user is allowed to make some words bold in the 'test' field of the message box: [[MessageBox type="warning" icon="yes" text="Claims filed between <strong>February 16 - December 10</strong> will receive a partial exemption for that year."]] The HannaCodeDialog won't recognize this as a valid HannaCode tag though. It just leaves it as is and doesn't convert it to a widget. The same happens if there is a link definition (<a href.....). Is there any remedy to this?
Robin S Posted October 16, 2019 Author Posted October 16, 2019 @msavard, in this module HTML tags are not supported inside attributes. But you could use Markdown for the same result, for example: In your attribute: Claims filed between **February 16 - December 10** will receive a [partial exemption](https://www.google.com) for that year. In your Hanna Tag code: <div class="message-box"><?= $sanitizer->entitiesMarkdown($text) ?></div>
BigRed Posted October 17, 2019 Posted October 17, 2019 That is very helpful, thank you! I didn't even know about that function. I will try it out tomorrow.
BigRed Posted October 17, 2019 Posted October 17, 2019 @Robin S, your solution worked perfectly! Thank you. 1
MilenKo Posted November 10, 2019 Posted November 10, 2019 Hey @Robin S I've been playing this weekend with HannaCode + Dialogue and was wondering, would you know a way to provide a label for the attribute options? Presently I have the following list of attributes: Post_sorting_order Post_sorting_order__options=date|-date|title|-title|phits|-phits|recipe_comments.count|-recipe_comments.count Post_sorting_order__description=Negative sign means reverse order and I am trying to presend the options in a more human readable form (eg. "-date" to become "Date - asscending") etc. It is not much to leave it as it is, however presently to sort by comments count I am using the fieldname.count instead of something like: Comments count (ascending/descending). I've tried to modify the module to have a value of the options like: Post_sorting_order__options=date*Date(Ascending)|-date*Date(Descending) etc. but so far I was not able to modify the code to make it work..
Robin S Posted November 10, 2019 Author Posted November 10, 2019 1 hour ago, MilenKo said: would you know a way to provide a label for the attribute options? This is possible if you use a hook to build the dialog form. See the example in the module readme. You would define the options like this: $wire->addHookAfter('HannaCodeDialog::buildForm', function(HookEvent $event) { // The Hanna tag that is being opened in the dialog $tag_name = $event->arguments(0); // Other arguments if you need them /* @var Page $edited_page */ $edited_page = $event->arguments(1); // The page open in Page Edit $current_attributes = $event->arguments(2); // The current attribute values $default_attributes = $event->arguments(3); // The default attribute values // The form rendered in the dialog /* @var InputfieldForm $form */ $form = $event->return; if($tag_name === 'your_hanna_tag_name') { $modules = $event->wire('modules'); /* @var InputfieldSelect $f */ $f = $modules->InputfieldSelect; $f->name = 'Post_sorting_order'; $f->id = 'Post_sorting_order'; $f->addOptions([ 'recipe_comments.count' => 'Recipe comments', '-recipe_comments.count' => 'Recipe comments (descending)', // etc ]); $form->add($f); } }); Or if you don't want to use a hook you just need to do the work of converting the labels into the values you want to sort by in the Hanna tag code. For example: switch($Post_sorting_order) { case 'Recipe comments': $sort = 'recipe_comments.count'; break; case 'Recipe comments (descending)': $sort = '-recipe_comments.count'; break; // etc } 1
MilenKo Posted November 11, 2019 Posted November 11, 2019 Hey,@Robin S thank you very much for the quick and useful info. I was playing with some ifs to have a name in the sorting and then convert it to the actual sorting form, however the 'case' switch seems much cleaner and simpler than my code. I will run a test with it and see how it would come out, but I am sure it would be perfect.
maddmac Posted March 20, 2020 Posted March 20, 2020 Is is possible to use the InputfieldSelectorSelectID module with the Hannacode dialog to make a page selector? Would this be built using some type of hook?
Robin S Posted March 20, 2020 Author Posted March 20, 2020 v0.3.0 released. Adds support for PageListSelect and PageListSelectMultiple inputfield types. Also adds support for PageAutocomplete inputfield type but only when used via a HannaCodeDialog::buildForm hook. From the module readme: Quote For selecting pages you can use pagelistselect or pagelistselectmultiple. You don't supply select options for these inputfield types. Quote PageAutocomplete inputfield type The PageAutocomplete inputfield type can only be used via a HannaCodeDialog::buildForm hook. See the PhpDoc documentation for the list of inputfield properties that may be set. Particularly findPagesSelector for limiting the pages that may be selected and maxSelectedItems for allowing only a single page selection. 10 hours ago, maddmac said: Is is possible to use the InputfieldSelectorSelectID module with the Hannacode dialog to make a page selector? @maddmac, I think you must be referring to PageListSelect which is used in InputfieldSelectorSelectID rather than that module as a whole. In v0.3.0 you can now use PageListSelect with HannaCodeDialog, either by setting a "attributename__type=pagelistselect" attribute in the tag settings or by using a HannaCodeDialog::buildForm hook. 3
maddmac Posted March 22, 2020 Posted March 22, 2020 On 3/20/2020 at 6:53 PM, Robin S said: Thanks for the info Robin. I did upgrade to 3.0. PageListSelect does appear to now display in Hanna Dialog but when I select the desired page the information is not being added back to the editor. See below [[button_link title="LEARN MORE" pageid=""]] I am using inside a Repeater Matrix On 3/20/2020 at 6:53 PM, Robin S said: v0.3.0 released. Adds support for PageListSelect and PageListSelectMultiple inputfield types. Also adds support for PageAutocomplete inputfield type but only when used via a HannaCodeDialog::buildForm hook. From the module readme: @maddmac, I think you must be referring to PageListSelect which is used in InputfieldSelectorSelectID rather than that module as a whole. In v0.3.0 you can now use PageListSelect with HannaCodeDialog, either by setting a "attributename__type=pagelistselect" attribute in the tag settings or by using a HannaCodeDialog::buildForm hook.
Robin S Posted March 23, 2020 Author Posted March 23, 2020 @maddmac, I tested here inside a repeater and it's working correctly. You might need to clear cached files from your browser to get the updated CKEditor plugins that are included in the module. As far as I know plugins don't get automatic cache busting in CKEditor and I don't know any way to do this manually due to the way external plugins are loaded. If you do a hard refresh in Page Edit it should fix things. 1
MarkE Posted April 12, 2020 Posted April 12, 2020 This is a great module that I have been using for some time. However, I have one slight issue, which may be an issue with CKEditor rather than with the module itself. For any hanna code longer than about 14 characters, the dropdown box cuts them off (see pic). Is there a way of widening the box to fit the longest code (and/or making the font size for the codes smaller)?
adrian Posted April 12, 2020 Posted April 12, 2020 @MarkE - there might be other ways, but what I do is use AOS's ability to add JS to the admin and use this: .cke_combopanel__hannadropdown { width:400px !important; min-height: 250px !important; } 3
Robin S Posted April 12, 2020 Author Posted April 12, 2020 11 hours ago, MarkE said: which may be an issue with CKEditor rather than with the module itself Yes, it's the styling CKEditor applies to all dropdowns - the Format and Style dropdowns are the same. I don't want to override the CKEditor defaults because the desired width for the dropdown will probably vary from person to person, but Adrian's solution is a good one. If you want to style the items (font size, etc) within any of the CKEditor dropdowns you can add custom CSS to /site/modules/InputfieldCKEditor/contents.css. For example, I don't like the "preview" styling added to items in the Format and Styles dropdown so I have this custom CSS: .cke_panel_list .cke_panel_listItem a * { font-family:sans-serif, Arial, Verdana, "Trebuchet MS"; color:#333; font-weight:normal; font-style:normal; text-transform:none; letter-spacing:0; font-size:14px; padding:0; margin:0; } 3
schwarzdesign Posted April 29, 2020 Posted April 29, 2020 Hi @Robin S, thanks for this module! I'm having a problem getting the toolbar element "Insert Hanna Tag" into the toolbar inside a nested RepeaterMatrix field. Everywhere else it's working fine, but it just won't appear on fields that are part of a RepeaterMatrix field that are nested inside another RepeaterMatrix field. They are loaded through AJAX, but I don't think it has something to do with that. It is working fine with a regular Repeater nested inside a RepeaterMatrix that is loaded through AJAX, for example. Do you have any idea what may be causing this? Thanks! EDIT: Ok scrap the above, the problem doesn't appear to be related to the fields being nested. In fact, ALL CKEditor fields that are part of a RepeaterMatrix field don't get the Hanna Dialog toolbar element. Regular repeaters work fine, even if nested inside a Repeater Matrix field. Maybe it has something to do with the way the module checks for CK Editor fields?
Robin S Posted April 29, 2020 Author Posted April 29, 2020 @schwarzdesign, I can't reproduce that issue - the toolbar dropdown appears inside Repeater Matrix fields and nested Repeater Matrix fields. Double-check that you have included "HannaDropdown" in the toolbar settings for the CKEditor field. 1
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