Function reference: Widgets

mm_widget_tags($fields, $delimiter, $source, $display_count, $roles, $templates)

Tags demo

Changes the manager widget for this text field to tag-friendly format - e.g. it will display a clickable list of all other tags which have been used for this field.

$fields: The name(s) of the template variables this should apply to. Can accept multiple field separated by a comma. [Required]
$delimiter: Which character separates individual tags within this field [Optional - default is comma)
$source: The names(s) of the template variables the list of tags should come from. This allows the list of tags to come from a different field that the widget. By default it uses all the TVs listed in $fields [Optional - default is same as $fields]
$display_count: Display the number of documents using each tag (in brackets after it) [Optional - boolean - default is false]
$roles: comma separated list of role IDs this should be applied to. Leave empty (or omit) for all roles [Optional - default is all]
$templates: comma separated list of template IDs this should be applied to. Leave empty (or omit) for all templates [Optional - default is all]

mm_widget_tags('docTags'); // Adds the tag editing widget to the docTags template variable wherever it appearsmm_widget_tags('docTags,blogTags'); // Adds the tag editing widget to the docTags and blogTags template variables wherever they appear - making all previous values from both template variables available in both tagsmm_widget_tags('docTags', ',', '', '1', '', '2'); // Adds the tag editing widget to the docTags template variables in template 2, and shows the number of times each tag has been used

Note: TV(s) must be a text input field

mm_widget_showimagetvs($fields, $w, $h, $thumbnailerUrl, $roles, $templates)

Show Image preview

Emulates the ShowImageTVs plugin - shows a preview of images chosen in image TVs.

$fields: The name(s) of the template variables this should apply to. Can accept multiple field separated by a comma. [Optional - default is to use all image TVs]
$w: Preferred maximum width of the preview [Optional - default is 300]
$h: Preferred maximum height of the preview [Optional - default is 100]
$thumbnailerUrl: If you have PHPThumb installed (for example through Maxigallery or phpthumb plugins/snippets), use this to make thumbnails rather than resizing the image previews via CSS. Particularly useful if you are using very large pictures, which would take a long time to download. [Optional - url]
$roles: comma separated list of role IDs this should be applied to. Leave empty (or omit) for all roles [Optional - default is all]
$templates: comma separated list of template IDs this should be applied to. Leave empty (or omit) for all templates [Optional - default is all]

mm_widget_showimagetvs(); // Adds an image preview to every Image-type template variablemm_widget_showimagetvs('', 150, 150); // Adds a 150x150px image preview to every Image-type template variablemm_widget_showimagetvs('mypic', '300', '200', '/assets/snippets/phpthumb/phpThumb.php', '', '2'); // Adds an image preview to the mypic template variables in template 2, resized to 300x200px using phpthumb at the URL supplied

Note: TV(s) must be an image input field

mm_widget_colors($fields, $default, $roles, $templates)

Color picker

Turns a text field into a color picker - storing the chosen hex value in the field.

$fields: The name(s) of the template variables this should apply to. Can accept multiple field separated by a comma. [Required]
$default: Which color should be selected by default in new documents. This is only used in situations where the TV does not have a default value specified in the TV definition [Optional - default is white)
$roles: comma separated list of role IDs this should be applied to. Leave empty (or omit) for all roles [Optional - default is all]
$templates: comma separated list of template IDs this should be applied to. Leave empty (or omit) for all templates [Optional - default is all]

mm_widget_colors('bgcolor'); // Adds the color picker widget to the bgcolor template variable wherever it appearsmm_widget_colors('bgcolor,foreground'); // Adds the color picker widget to the bgcolor and foreground template variables wherever they appearmm_widget_colors('bgcolor', '#000000', '1', '2'); // Adds the color picker widget to the bgcolor template variable, with a default value of black for new documents, only for role 1 and documents using template 2

Note: TV(s) must be a text input field

 

mm_widget_accessdenied($ids, $message, $roles)

Denies access to specific documents (by ID) without inheritance.

For example, if the parent document has some Ditto call (which you do not want a user to edit) but want to allow them to create child documents.

Use this plugin with caution, as while it offers a basic level of protection, it does not prevent access to documents in the same way as ModX's permissions system. It would be possible for a user with technical knowledge to override it. Think of it as a "No entry" sign for an unlocked door, rather than a lock.

Originally contributed by Metaller

$ids: comma separated list of documents ID to prevent access. [Required]
$message: HTML formatted message [Optional - default is "Access denied - Access to current document closed for security reasons.")
$roles: comma separated list of role IDs this should be applied to. Leave empty (or omit) for all roles [Optional - default is all]

mm_widget_accessdenied('1,15'); // Prevents all users from accessing documents 1 and 15 (displaying default message)mm_widget_accessdenied('1,15', 'Please select another document to edit' '2'); // Prevents users with role 2 from accessing documents 1 and 15 (displaying custom message)