Snippet Tips and Tricks

Snippet Properties and Property Sets

gourmet fare

Select Element Options

MODX has a feature that allows you to drag a snippet into a text field in an Element or a Resource that you are editing. A form will pop up offering fields to fill out to make inserting the MODX tags easier for you. This recipe comes from a GitHub issue posting.

sottwell asked...

how does MODX determine what snippet properties to provide fields for in the Select Element Options form popup?

The Solution:

Jako says...

The popup is created with the property set of the dragged snippet. The property set is normally created during the installation of a snippet (if the snippet author created the set).

What's the Story?

Instead of typing out snippet tags with the properties you need to configure it to work the way you want, MODX provides a neat drag-and drop feature that lets you simply drag the snippet you want to use over and drop it in the editing panel's text or textarea fields exactly where you want to put it. MODX will also provide a form popped up to allow you to select the snippet's property set or fill out fields to create the snippet's properties in the snippet tags. But as Jako said, only if the snippet author created the set or the properties.

This is what the form looks like when the snippet's author has created the set of properties.

Select Element Options form

And this is what FormIt's Default Properties looks like.

FormIt Default Properties

Without a snippet's Default Properties set, or a Property Set created for it, the popup form will only have the Cached and Property Set fields available.Your users will still have to type in all of its properties.

So do your users a favor and fill out your snippet's Default Properties or create a Property Set for it so that MODX can give them a form to make calling your snippet easier.