MarkE Posted February 11, 2021 Share Posted February 11, 2021 1 hour ago, Robin S said: Or here's a hacky solution that involves adding an extra "path" attribute to your Hanna tag.. Brilliant - thanks. I was thinking along those lines, but obviously not hacky enough 😁 1 Link to comment Share on other sites More sharing options...
MarkE Posted February 12, 2021 Share Posted February 12, 2021 12 hours ago, Robin S said: Or here's a hacky solution that involves adding an extra "path" attribute to your Hanna tag... Just to report that this works well. I also added some css to hide the path attribute in the dialog box, so as not to confuse the user or risk inadvertant amendment. Super module , super support! Link to comment Share on other sites More sharing options...
MarkE Posted February 13, 2021 Share Posted February 13, 2021 Following the above discussion, I decided that it made more sense to display the title rather than the path (since it is only for display purposes). I also wanted a solution for attribute types pagelistselectmultiple, not just pagelistselect. In case it is useful to anyone else, my suggested js is: $(document).ready(function() { /* Author: Mark Evens, based on an original script by Robin Sallis */ /* This version displays the title text rather than the path name */ /* It also works for pagelistselectmultiple as well as pagelistselect */ /* Hide the text field */ /* id_title is the name of a text attribute in the hanna code*/ /* change id_title throughout the code below to match your attribute name */ $('#wrap_id_title').addClass('hide-field'); // Must use mousedown instead of click event due to frustrating event propagation issues across PW core // https://github.com/processwire/processwire-issues/issues/1028 // .PageListActionSelect is the button 'Select' with appears when a page is clicked (no normally visible - loaded by js) $(document).on('mousedown', '.PageListActionSelect a', function (event) { var id_title; // Adapt unselect label to suit your language if ($(this).text() === 'Unselect') { id_title = ''; } else { id_title = ($(this).closest('.PageListItem').children('.PageListPage').text()); // replace .text() by .attr('title') for path name } $('#id_title').val(id_title); }); // For pagelistselectmultiple, get all the selected pages when the selection is updated // This returns the contents of the label displayed in the pagelist item. This can be set in your HannaCodeDialog::buildForm hook // The default is the page title. For the path name, set $f->labelFieldName = 'path'; in your hook $(document).on('change', '.InputfieldPageListSelectMultiple', function(event) { var id_title = []; $(this).find('.InputfieldContent ol li:not(.itemTemplate)').each(function(){ id_title.push($(this).children('span.itemLabel').text()) }) $('#id_title').val(id_title); }); }); To hide the id_title attribute in the dialog, you need to add the following css: #hanna-form .hide-field { display: none !important; } 3 Link to comment Share on other sites More sharing options...
adrian Posted February 13, 2021 Share Posted February 13, 2021 @Robin S - I have been using this module since it was released and always thought it was a necessary tool for inserting Hanna codes, but I just starting using some of its other features like: linked_page__pagelistselect which makes it an entirely new beast - amazing. Thanks! 4 Link to comment Share on other sites More sharing options...
adrian Posted February 18, 2021 Share Posted February 18, 2021 @Robin S - just discovered that if you have this attached to a field that is editable under a user's profile page, it breaks the field with a JS error because it can't load this component. No rush for a fix for my needs, but someone else might come across it. 1 Link to comment Share on other sites More sharing options...
Robin S Posted February 19, 2021 Author Share Posted February 19, 2021 Thanks for the report @adrian. The newly released v0.3.6 adds support for ProcessProfile and ProcessUser, and also adds a config field to show the Tracy debug bar in the dialog which can be helpful for debugging if you are building the dialog form with a hook. 4 Link to comment Share on other sites More sharing options...
adrian Posted February 19, 2021 Share Posted February 19, 2021 Thanks @Robin S - sounds great! Link to comment Share on other sites More sharing options...
adrian Posted February 23, 2021 Share Posted February 23, 2021 @Robin S - I am trying to offer selection of an uploaded file and not sure if I am taking the most efficient approach, but either way, it's not quite working. I am using https://processwire.com/modules/fieldtype-select-file/ to give me a InputfieldSelectFile $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 === 'audio') { $modules = $event->wire('modules'); /* @var InputfieldSelect $f */ $f = $modules->InputfieldSelectFile; $f->name = 'selected_file'; $f->id = 'selected_file'; $f->label = 'Select File'; $f->folderPath = 'assets/files/'.$edited_page->id.'/'; $form->add($f); } }); All looks good so far, but then I end up with: Any ideas what I might be doing wrong, or if there is a better way? FYI, I had to change the root path in that File Select module to start at /site/ instead of /site/templates/ Thanks for any thoughts! Link to comment Share on other sites More sharing options...
Robin S Posted February 23, 2021 Author Share Posted February 23, 2021 4 minutes ago, adrian said: I am using https://processwire.com/modules/fieldtype-select-file/ to give me a InputfieldSelectFile If you're using non-core inputfields beyond those described in the module readme it will be a case of "your mileage may vary" and I can't really offer support for those kinds of cases. I suggest just using a normal InputfieldSelect and setting the options from files in Files field(s) on the page, or via $files->find()/DirectoryIterator/glob. 1 Link to comment Share on other sites More sharing options...
adrian Posted February 23, 2021 Share Posted February 23, 2021 7 minutes ago, Robin S said: I suggest just using a normal InputfieldSelect and setting the options from files in Files field(s) on the page Of course - that works perfectly, thank you! 1 Link to comment Share on other sites More sharing options...
Ivan Gretsky Posted March 22, 2021 Share Posted March 22, 2021 Good day and once again thanks for the great module! Is it possible to use ckeditor as an inputfield for text? I am trying to create a readmore hannacode and need to provide a rich text input for the content to be only partly shown. Link to comment Share on other sites More sharing options...
Robin S Posted March 22, 2021 Author Share Posted March 22, 2021 9 hours ago, Ivan Gretsky said: Is it possible to use ckeditor as an inputfield for text? No, CKEditor isn't a supported inputfield. I expect it would create rendering issues in the tag if it contains HTML, and if you are putting anything more than a short piece of text in your "read more" it would result in a huge, cumbersome tag widget. Instead I think you should wrap the "read more" text in "open" and "close" Hanna tags. [[rm-open]] <p>Your text here.</p> [[rm-close]] Then replace the [[rm-open]] with a "Read more..." button and a div open tag, and the [[rm-close]] with a div close tag. Use JS to toggle the visibility of the div when the button is clicked. You could also look at TextformatterPagination and TextformatterAccordion for inspiration but I think the above method would be the simplest. 1 Link to comment Share on other sites More sharing options...
adrian Posted April 7, 2021 Share Posted April 7, 2021 @Robin S - Ryan's update to the HannaCode module yesterday has broken this. Looks like it's probably just because he namespaced it, so should be an easy fix. PS - @teppo - I wonder if your HannaCodeHelper module might suffer the same fate? 2 1 Link to comment Share on other sites More sharing options...
Robin S Posted April 8, 2021 Author Share Posted April 8, 2021 On 4/8/2021 at 3:18 AM, adrian said: Ryan's update to the HannaCode module yesterday has broken this. Looks like it's probably just because he namespaced it, so should be an easy fix. Thanks. The v0.3.0 update to HannaCode is actually a major refactoring of the module so there were a few things in HannaCodeDialog that needed updating for compatibility. The new v0.4.0 of HannaCodeDialog should be compatible with HannaCode v0.3.0 and it requires HannaCode >= v0.3.0. 6 2 Link to comment Share on other sites More sharing options...
adrian Posted April 9, 2021 Share Posted April 9, 2021 Thanks @Robin S - new version looks good. 1 Link to comment Share on other sites More sharing options...
Macrura Posted June 26, 2021 Share Posted June 26, 2021 @Robin S I'm having some issues with getting this to work – using the latest PW, and Hanna Code, and Hanna Code Dialog; The field with the hanna codes (body) isn't wrapping the codes so they just look like text and don't get identified as widgets. Not sure what i'm doing wrong; Tried uninstalling everything and re-install, but since the upgrades, no widgets; The HCD was working fine before I upgraded it... thanks for any insights you might have - looking forward to using this on a particular project.. Link to comment Share on other sites More sharing options...
Robin S Posted June 26, 2021 Author Share Posted June 26, 2021 55 minutes ago, Macrura said: The field with the hanna codes (body) isn't wrapping the codes so they just look like text and don't get identified as widgets. That sounds like a JavaScript issue - have a look for errors in the browser console. I just checked with the latest PW/HannaCode/HannaCodeDialog and it all seems to be working here. 1 Link to comment Share on other sites More sharing options...
Macrura Posted June 26, 2021 Share Posted June 26, 2021 Thanks!! - i just did another test and figured out the problem – tt only recognizes the shortcodes if you have the Hanna Code textformatter applied to the field. I'm not actually using Hanna Code, i'm processing the shortcodes with my own textformatter, but using your module to enable editing of my custom shortcodes... In any case, you're right and it completely works now; I have the Hanna Code Textformatter after my textformatter so it won't do anything (the codes will all be processed by the time it hits that one).. Link to comment Share on other sites More sharing options...
adrian Posted June 27, 2021 Share Posted June 27, 2021 @Macrura - thanks to @Robin S in another post: https://processwire.com/talk/topic/15902-hannacodedialog/?do=findComment&comment=208498 // add hanna code dialog to fields even though the Hanna code text formatter isn't applied // https://processwire.com/talk/topic/15902-hannacodedialog/?do=findComment&comment=208498 $this->wire()->addHookAfter('InputfieldCKEditor::renderReadyHook', function (HookEvent $event) { $inputfield = $event->object; $field = $inputfield->hasField; // For your field name(s)... if(!$field || $field->name !== 'XXXX') return; $config_name = "InputfieldCKEditor_{$field->name}"; $config_name_matrix = "InputfieldCKEditor_{$field->name}_matrix"; $config = $this->wire('config'); $js_config = $config->js(); foreach($js_config as $key => $value) { if($key === $config_name || strpos($key, $config_name_matrix) === 0) { $js_config[$key]['extraPlugins'] .= ',hannadropdown,hannadialog'; $config->js($key, $js_config[$key]); } } }); 2 Link to comment Share on other sites More sharing options...
Macrura Posted June 29, 2021 Share Posted June 29, 2021 Couple of questions and issues... (1) On 2/11/2021 at 5:35 PM, Robin S said: // Add JS file to Hanna Code Dialog form $js_file = $config->paths->templates . 'hannas/select_page.js'; if(is_file($js_file)) { $js_url = $config->urls->templates . 'hannas/select_page.js?v=' . filemtime($js_file); $form->appendMarkup = "<script src='$js_url'></script>"; } For some reason I can't get this to work at all; not sure why but my hook is in ready.php, and the markup is not appended to the form. I put my js into ACF ProcessPageEdit.js and that works, but it would be interesting to know why the code above didn't work, in case i wanted to keep the js file along with my other hanna code stuff. (2) I enabled Tracy in the form (module config), but not getting any tracy...not loading. Wondering if there is any way to troubleshoot that. (3) The CK editor widget things are great, makes it much easier for editors to see where a code is, and of course double click it to edit parameters. But one thing that is tricky is getting the cursor in front of a widget, if it is the first thing in the editor. For me no problem of course i can just switch to code mode and put in some placeholder in front of it; but for the average user, i do wonder if there is any solution to this... thanks! Link to comment Share on other sites More sharing options...
Robin S Posted June 29, 2021 Author Share Posted June 29, 2021 5 hours ago, Macrura said: the markup is not appended to the form Double-check that the path to your JS file is correct, because that conditional will only append the script markup if is_file() is true. With some debugging (see item 2) hopefully you can get it working. I just tested here again and it works for me. 5 hours ago, Macrura said: (2) I enabled Tracy in the form (module config), but not getting any tracy The label of that config setting is perhaps not perfect - I'll update it. The setting doesn't actually ensure that Tracy is displayed, rather it only disables the default CSS in the module that would otherwise hide the Tracy debug bar. <?php if(!$hcd->show_tracy): ?> #tracy-debug { display:none !important; } <?php endif; ?> So you first need to have Tracy set to display the debug bar in the PW admin generally and then if you have that HCD setting checked it won't be hidden in the dialog. 5 hours ago, Macrura said: But one thing that is tricky is getting the cursor in front of a widget There's not much I can do about that because it's just how the CKEditor Widget plugin works. In such a situation I tend to use the arrow keys to move the cursor to the start of the field, or type the text underneath and then drag the widget to its new position. 1 Link to comment Share on other sites More sharing options...
Macrura Posted June 29, 2021 Share Posted June 29, 2021 Many thanks for your post and help! All has been revealed, and some facepalm moments... (1) had to change $config to wire('config') (🤦♂️) (2) had to set Tracy config to show in dialog (🤦♂️) (3) Yep, i'll just tell people up front if they need to put something in front of it, they need to move the widget.. 1 Link to comment Share on other sites More sharing options...
adrian Posted December 15, 2021 Share Posted December 15, 2021 Hi @Robin S - just wondering if it would be difficult to make this appear in the Profields Table field for CkEditor Textareas? I know they use CkEditor's inline mode so not sure if that is a problem or not. Thanks. 1 Link to comment Share on other sites More sharing options...
Robin S Posted December 15, 2021 Author Share Posted December 15, 2021 Hi @adrian, thanks for the report. Please update to v0.4.4 and it should work. 2 Link to comment Share on other sites More sharing options...
adrian Posted December 15, 2021 Share Posted December 15, 2021 2 minutes ago, Robin S said: Hi @adrian, thanks for the report. Please update to v0.4.4 and it should work. Thank you so much for the quick response - working perfectly! 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