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.

Parameter Type Desctiption Default
$fields string; comma separated string The name(s) of the template variables this should apply to. Required
$delimiter string Which character separates individual tags within this field Optional: Default: ','
$source string; comma separated string 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: = $fields
$display_count 0; 1 Display the number of documents using each tag (in brackets after it). Optional; Default: 0
$roles string; comma separated string List of role IDs this should be applied to. Leave empty (or omit) for all roles. Optional; Default: ''
$templates string; comma separated string List of template IDs this should be applied to. Leave empty (or omit) for all templates. Optional; Default: ''.

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.

Parameter Type Desctiption Default
$fields string; comma separated string The name(s) of the template variables this should apply to. Optional; Default: '' (is to use all image TVs)
$w integer Preferred maximum width of the preview. Optional; Default: 300
$h integer Preferred maximum height of the preview. Optional; Default: 300
$thumbnailerUrl url string 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
$roles string; comma separated string List of role IDs this should be applied to. Leave empty (or omit) for all roles. Optional; Default: ''
$templates string; comma separated string List of template IDs this should be applied to. Leave empty (or omit) for all templates. Optional; Default: ''

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.

Parameter Type Desctiption Default
$fields string; comma separated string The name(s) of the template variables this should apply to. Required
$default color string 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: '#ffffff'
$roles string; comma separated string List of role IDs this should be applied to. Leave empty (or omit) for all roles. Default: ''
$templates string; comma separated string List of template IDs this should be applied to. Leave empty (or omit) for all templates. Default: ''

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

Parameter Type Desctiption Default
$ids string; comma separated string List of documents ID to prevent access. Required
$message html string HTML formatted message Optional; Default: '"Access denied - Access to current document closed for security reasons."'
$roles string; comma separated string List of role IDs this should be applied to. Leave empty (or omit) for all roles. Optional; Default: ''

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)

mm_ddGMap($tvs, $roles, $templates, $w, $h)

Integrate the Google Maps in MODx documents.

Parameter Type Desctiption Default
$tvs string; comma separated string The name(s) of the template variables this should apply to. Required
$roles string; comma separated string List of role IDs this should be applied to. Leave empty (or omit) for all roles. Optional; Default: ''
$templates string; comma separated string List of template IDs this should be applied to. Leave empty (or omit) for all templates. Optional; Default: ''
$w string; integer Width of container map. Optional; Default: 'auto'
$h integer Height of container map. Optional; Default: 400

Created by DivanDesign.

mm_ddYMap($tvs, $roles, $templates, $key, $w, $h)

Integrate the Yandex Maps in MODx documents.

Parameter Type Desctiption Default
$tvs string; comma separated string The name(s) of the template variables this should apply to. Required
$roles string; comma separated string List of role IDs this should be applied to. Leave empty (or omit) for all roles. Optional; Default: ''
$templates string; comma separated string List of template IDs this should be applied to. Leave empty (or omit) for all templates. Optional; Default: ''
$key string Yandex-map key for your domain. Required
$w string; integer Width of container map. Optional; Default: 'auto'
$h integer Height of container map. Optional; Default: 400

Created by DivanDesign.

mm_ddSetFieldValue($field, $value, $roles, $templates)

Sets a value for a field (always!).

Parameter Type Desctiption Default
$field string The name of the document field or template varible this should apply to. Required
$value string The value for the field specified. Optional; Default: ''
$roles comma separated string List of role IDs this should be applied to. Leave empty (or omit) for all roles. Optional; Default: ''
$templates comma separated string List of template IDs this should be applied to. Leave empty (or omit) for all templates. Optional; Default: ''

Created by DivanDesign.

mm_ddMaxLength($tvs, $roles, $templates, $length)

Limit the number of characters in the TV (like the Twitter).

Parameter Type Desctiption Default
$tvs comma separated string The name(s) of the template variables this should apply to. Required
$roles comma separated string List of role IDs this should be applied to. Leave empty (or omit) for all roles. Optional; Default: ''
$templates comma separated string List of template IDs this should be applied to. Leave empty (or omit) for all templates. Optional; Default: ''
$length integer Count of characters to limit. Optional; Default: 150

Created by DivanDesign.

mm_ddAutoFolders($ddRoles, $ddTemplates, $ddParent, $ddDateSource, $ddYearTpl, $ddMonthTpl, $ddYearPub, $ddMonthPub)

Automatically move documents (OnBeforeDocFormSave event) based on their date (publication date; any date in tv) into folders of year and month (like 2012/02/).

If folders (documents) of year and month doesn`t exist they are created automatically OnBeforeDocFormSave event.

Parameter Type Desctiption Default
$ddRoles comma separated string List of role IDs this should be applied to. Leave empty (or omit) for all roles. Optional; Default: ''
$ddTemplates comma separated string List of template IDs this should be applied to. Leave empty (or omit) for all templates. Optional; Default: ''
$ddParent integer Ultimate parent ID (parent of the years). Required
$ddDateSource string Name of template variable which contains the date. Optional; Default: 'pub_date'
$ddYearTpl integer Template ID for documents of year. Optional; Default: 0
$ddMonthTpl integer Template ID for documents of month. Optional; Default: 0
$ddYearPub 0; 1 Would the documents of year published? Optional; Default: 0
$ddMonthPub 0; 1 Would the documents of month published? Optional; Default: 0

Created by DivanDesign.