Jump to content


Robin S

Recommended Posts

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 😁

  • Like 1
Link to comment
Share on other sites

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

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 */

    // 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

    // 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(){


To hide the id_title attribute in the dialog, you need to add the following css:

#hanna-form .hide-field {
  display: none !important;


  • Like 3
Link to comment
Share on other sites

@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.


  • Like 4
Link to comment
Share on other sites

@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.

  • Like 1
Link to comment
Share on other sites

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.

  • Like 4
Link to comment
Share on other sites

@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.'/';





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

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.

  • Like 1
Link to comment
Share on other sites

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!

  • Like 1
Link to comment
Share on other sites

  • 4 weeks later...

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

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.

<p>Your text here.</p>

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.

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...

@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?

  • Like 2
  • Thanks 1
Link to comment
Share on other sites

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.

  • Like 6
  • Thanks 2
Link to comment
Share on other sites

  • 2 months later...

@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

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.

  • Like 1
Link to comment
Share on other sites

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

@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]);


  • Like 2
Link to comment
Share on other sites

Couple of questions and issues...


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...




Link to comment
Share on other sites

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.


  • Like 1
Link to comment
Share on other sites

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..

  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Similar Content

    • By MarkE
      This fieldtype and inputfield bundle was built for storing measurement values within a field, rendering them in a variety of formats and converting them to other units or otherwise modifying them via the API.
      The API consists of a number of predefined functions, some of which include...
      render() for rendering the measurement object, valueAs() for converting the value to another unit value, convertTo() for converting the whole measurement object to different units, and add() and subtract() for for modifying the stored value by the value (converted as required) in another measurement. In the admin the inputfield includes a checkbox (which can be optionally disabled) for converting values on page save. For an example if a value was typed in as centimeters, the unit was changed to metres, and the page saved with this checkbox selected, said value would be automatically converted so that e.g. 170 cm becomes 1.7 m.

      A simple length field using Fieldtype Measurement and Inputfield Measurement.
      Combination units (e.g. feet and inches) are also supported.
      Please note that this module is 'proof of concept' at the moment - there are limited units available and quite a lot of code tidying to do. More units will be added shortly.
      See the GitHub at https://github.com/MetaTunes/FieldtypeMeasurement for full details and updates.
    • By tcnet
      File Manager for ProcessWire is a module to manager files and folders from the CMS backend. It supports creating, deleting, renaming, packing, unpacking, uploading, downloading and editing of files and folders. The integrated code editor ACE supports highlighting of all common programming languages.

      This module is probably the most powerful module. You might destroy your processwire installation if you don't exactly know what you doing. Be careful and use it at your own risk!
      ACE code editor
      This module uses ACE code editor available from: https://github.com/ajaxorg/ace

      This module uses the JavaScript dragscroll available from: http://github.com/asvd/dragscroll. Dragscroll adds the ability to drag the table horizontally with the mouse pointer.
      PHP File Manager
      This module uses a modified version of PHP File Manager available from: https://github.com/alexantr/filemanager
    • By tcnet
      This module implements the website live chat service from tawk.to. Actually the module doesn't have to do much. It just need to inserted a few lines of JavaScript just before the closing body tag </body> on each side. However, the module offers additional options to display the widget only on certain pages.
      Create an account
      Visit https://www.tawk.to and create an account. It's free! At some point you will reach a page where you can copy the required JavaScript-code.

      Open the module settings and paste the JavaScript-code into the field as shown below. Click "Submit" and that's all.

      Open the module settings
      The settings for this module are located int the menu Modules=>Configure=>LiveChatTawkTo.

    • By tcnet
      Session Viewer is a module for ProcessWire to list session files and display session data. This module is helpful to display the session data of a specific session or to kick out a logged in user by simply delete his session file. After installation the module is available in the Setup menu.

      The following conditions must be met for the module to work properly:
      Session files
      Session data must be stored in session files, which is the default way in ProcessWire. Sessions stored in the database are not supported by this module. The path to the directory where the session files are stored must be declared in the ProcessWire configuration which is by default: site/assets/sessions.
      Serialize handler
      In order to transform session data easier back to a PHP array, the session data is stored serialized. PHP offers a way to declare a custom serialize handler. This module supports only the default serialize handlers: php, php_binary and php_serialize. WDDX was dropped in PHP 7.4.0 and is therefore not supported by this module as well as any other custom serialize handler. Which serialize handler is actually used you can find out in the module configuration which is available under Modules=>Configure=>SessionViewer.

      Session data
      The session data can be displayed in two different ways. PHP's default output for arrays print_r() or by default for this module nice_r() offered on github: https://github.com/uuf6429/nice_r. There is a setting in the module configuration if someone prefers print_r(). Apart from the better handling and overview of the folded session data the output of nice_r() looks indeed nicer.

      ProcessWire module directory
    • By Robin S
      Repeater Easy Sort
      Adds a compact "easy-sort" mode to Repeater and Repeater Matrix, making those fields easier to sort when there are a large number of items.
      The module also enhances Repeater Matrix by allowing a colour to be set for each matrix type. This colour is used in the item headers and in the "add new" links, to help visually distinguish different matrix types in the inputfield.
      A Repeater field

      A Repeater Matrix field with custom header colours

      Easy-sort mode
      Each Repeater/Matrix item gets an double-arrow icon in the item header. Click this icon to enter easy-sort mode.
      While in easy-sort mode:
      The items will reduce in width so that more items can be shown on the screen at once. The minimum width is configurable in the field settings. Any items that were in an open state are collapsed, but when you exit easy-sort mode the previously open items will be reopened. You can drag an item left/right/up/down to sort it within the items. The item that you clicked the icon for is shown with a black background. This makes it easier to find the item you want to move in easy-sort mode. You can click an item header to open the item. An "Exit easy-sort mode" button appears at the bottom of the inputfield. Configuration
      In the field settings for Repeater and Repeater Matrix fields you can define a minimum width in pixels for items in easy-sort mode. While in easy-sort mode the items will be sized to neatly fill the available width on any screen size but will never be narrower than the width you set here.
      In the field settings for Repeater Matrix you can define a custom header colour for each matrix type using an HTML "color" type input. The default colour for this type of input is black, so when black is selected in the input it means that no custom colour will be applied to the header.
      The easy-sort mode is only possible on Repeater/Matrix fields that do not use the "item depth" option.
  • Create New...