Robin S Posted May 1, 2019 Share Posted May 1, 2019 Thanks to @Macrura for the idea behind this module. Page Field Info Adds information about options in Page Reference fields. Supports InputfieldSelect and inputfields that extend InputfieldSelect: InputfieldSelect InputfieldRadios InputfieldSelectMultiple InputfieldCheckboxes InputfieldAsmSelect Requires ProcessWire >= 3.0.61 and AdminThemeUikit. Screenshots Field config Example of changes to inputfield Example of info field filled out in Page Edit Installation Install the Page Field Info module. Configuration In the Input tab of the settings for a Page Reference field... Tick the "Add info tooltips to options" checkbox to enable tooltips for the options in the field. Tooltips are not possible for Select or AsmSelect inputfield types so for those types you would want to tick the next option. Tick the "Append info about selected options" checkbox to append information about the selected options to the bottom of the inputfield. If the Page Reference field is a "multiple pages" field then the info for each selected option will be prefixed with the option label (so the user will know what option each line of info relates to). In the "Info field" dropdown select a text field that will contain information about the page, to be used in the tooltips and appended info. Of course this field should be in the template(s) of the selectable pages for the Page Reference field. Hook In most cases the "Info field" will supply the text for the tooltips and appended info, but for advanced usages you can hookPageFieldInfo::getPageInfo() to return the text. For example: $wire->addHookAfter('PageFieldInfo::getPageInfo', function(HookEvent $event) { $page = $event->arguments(0); // The page $inputfield = $event->arguments(1); // InputfieldPage $field = $event->arguments(2); // The Page Reference field $info = $event->return; // Text from the info field, if any // Set some custom text as the $event->return... }); https://github.com/Toutouwai/PageFieldInfohttps://modules.processwire.com/modules/page-field-info/ 15 Link to comment Share on other sites More sharing options...
Macrura Posted May 1, 2019 Share Posted May 1, 2019 Astounding! I'm installing now on several sites! Working great so far, had to change line 195 to support textarea, as that's what i use for the info $text_fields = $this->wire('fields')->find('type=FieldtypeText|FieldtypeTextarea'); Testing the single select now, but noticing that the options don't have the data-info attribute, so there is no way to update the selected option's description by javascript – do you think it is possible to add the data-info to the options on plain selects? 3 Link to comment Share on other sites More sharing options...
Robin S Posted May 1, 2019 Author Share Posted May 1, 2019 9 hours ago, Macrura said: had to change line 195 to support textarea, as that's what i use for the info I've added this to v0.1.1. 9 hours ago, Macrura said: Testing the single select now, but noticing that the options don't have the data-info attribute, so there is no way to update the selected option's description by javascript – do you think it is possible to add the data-info to the options on plain selects? There are data-info attributes on select options - maybe your browser dev tools don't display those attributes for some reason? 2 Link to comment Share on other sites More sharing options...
Macrura Posted May 2, 2019 Share Posted May 2, 2019 ok got it, i didn't get that for single select you have to check the tooltips option for this to work.. it's working now once i checked that... Maybe the description of that field could be modified to say that it is required to check that box for single select fields... thanks again! 2 Link to comment Share on other sites More sharing options...
Robin S Posted May 2, 2019 Author Share Posted May 2, 2019 20 minutes ago, Macrura said: i didn't get that for single select you have to check the tooltips option for this to work Sorry, I didn't understand the original issue properly before. You shouldn't have to activate the tooltip option for the append option to work for selects - I've fixed the logic in v0.1.2 so it should work as expected now. 2 Link to comment Share on other sites More sharing options...
Macrura Posted May 2, 2019 Share Posted May 2, 2019 It's working great, i have it on about 20 fields now on 1 current/major project and this going to really make a world of difference in reducing support (calls/emails/trello cards)... I've noticed the more of these sorts of things i put in the admin (including stuff like Field Descriptions Extended, Context help for templates, and ProcessDocumentation), the more careful clients are to check before wasting my support resources... 3 Link to comment Share on other sites More sharing options...
MarkE Posted September 11, 2023 Share Posted September 11, 2023 Is intended that the tooltips only work with checkboxes, not asmselect or select multiple? Otherwise is there something I need to get it working? It's a nice addition for checkboxes, but for asmselect it seems I have to stick with custom label formats. Link to comment Share on other sites More sharing options...
Robin S Posted September 12, 2023 Author Share Posted September 12, 2023 3 hours ago, MarkE said: Is intended that the tooltips only work with checkboxes, not asmselect or select multiple? From the readme: On 5/1/2019 at 5:02 PM, Robin S said: Tick the "Add info tooltips to options" checkbox to enable tooltips for the options in the field. Tooltips are not possible for Select or AsmSelect inputfield types so for those types you would want to tick the next option. 1 Link to comment Share on other sites More sharing options...
gornycreative Posted May 26 Share Posted May 26 I like what this does a lot. Have you considered allowing an image field to be selected and using, say, a thumbnail of the first image in the field to be shown? Link to comment Share on other sites More sharing options...
gornycreative Posted May 26 Share Posted May 26 My reason for looking into this is for things like a style block selection or a font selection - it would be great to be able to show an image below the selection instead of text. I'm not sure how well it would work for tooltips. Link to comment Share on other sites More sharing options...
Robin S Posted May 27 Author Share Posted May 27 3 hours ago, gornycreative said: Have you considered allowing an image field to be selected and using, say, a thumbnail of the first image in the field to be shown? For a case like this you can use the hookable method to return any markup you like, including an image. It won't work for a UIkit tooltip though because that only supports text. Example: $wire->addHookAfter('PageFieldInfo::getPageInfo', function(HookEvent $event) { $page = $event->arguments(0); // The page $inputfield = $event->arguments(1); // InputfieldPage $field = $event->arguments(2); // The Page Reference field // Return custom markup if($field->name === 'colour') { $image = $page->get('image[0]'); if($image) $event->return = "<img src='$image->url' alt='$image->description' style='max-width:200px; max-height:200px; margin-top:10px;'>"; } }); 1 Link to comment Share on other sites More sharing options...
gornycreative Posted May 27 Share Posted May 27 That makes sense. I'll look for more hookable stuff - I always forget to do that for mods. 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