Toutouwai / PageFieldInfo

Adds information about options in Page Reference fields.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Page Field Info

A module for ProcessWire CMS/CMF. 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

Field config

Example of changes to inputfield

Inputfield

Example of info field filled out in Page Edit

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/textarea 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 hook PageFieldInfo::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...
});

About

Adds information about options in Page Reference fields.

License:Mozilla Public License 2.0


Languages

Language:PHP 87.7%Language:JavaScript 11.4%Language:CSS 0.9%