Well, I have been working on building an extension for ColdFusion builder. I wanted to make it so that the menu for the extension was based on what was selected. This seemed simple but the documentation on extensions was a bit lacking in this area. But, after digging, searching, and looking at examples, I was able to figure it out.

There are two core ways to do a filter. The first is by the entire menu itself. The second is by the action in the menu.

So, lets say I wanted to display the menu only when a user selected a directory. The menu would look like this..

view plain print about
1<menu name="My Extension Menu">
2    <filters>
3        <filter type="folder" />
4    </filters>
5    <action name="My action" handlerid="actionHandler" showresponse="true">
6</menu>

This is good... I can also add a pattern to the filter to have it filter not only on a directory but possibly on the directory name. This can be done using regular expressions. This example will only work if the directory name is "style".

view plain print about
1<menu name="My Extension Menu">
2    <filters>
3        <filter type="folder" pattern="style" />
4    </filters>
5    <action name="My action" handlerid="actionHandler" showresponse="true">
6</menu>

Creating filtered menus is great. But, you will need to create an entire menu node for each filter. You can end up with bloated XML very quickly. This is where assigning the filter to the action comes into play. This allows for the same menu but different actions.

This example below will display two different actions for the same menu. The first is if the user selected a directory. The other is if they selected an XML file.

view plain print about
1<menu name="My Extension Menu">
2    <action name="My action - Folder" handlerid="actionHandlerFolder" showresponse="true">
3        <filters>
4            <filter type="folder" />
5        </filters>
6    </action>
7    <action name="My action - File" handlerid="actionHandlerFile" showresponse="true">
8        <filters>
9            <filter type="file" pattern=".*\.(xml)"/>
10        </filters>
11    </action>
12</menu>

You can read more about it here on the Adobe help Docs

Till next time..

--Dave