An MXP file is nothing more than a package containing all the separate files that constitute an extension, along with a set of instructions on where each file should go and what changes should be made to menus .xml to support the extension. Creating an MXP involves collecting all the files, coding the instructions as an XML file, and using the Extension Manager to generate the package. Aside from a brief dip into some new XML, all the hard work is done by the time you're ready to package. Task 1: Collect your materials This sounds easy. Create a folder, somewhere outside the Configuration folder, and copy all the various files that constitute your extension into this folder. If your extension consists of only one or two files, and you're not creating any custom subfolders , it's a no-brainer. For more complex extensions, it takes a little bit of planning to assure that no one gets left out. Some tips:
note Technically, collecting the files is optional. It is possible to create an MXP package while your various extension files are still in their Development folders, scattered throughout the Dreamweaver Configuration folder. It's much easier, however, and safer to keep track of the files to be packaged if they're all in one place. Collecting Materials for a Simple Extension: Set Page Properties Behavior (Chapter 3, Workshop #2)This simple behavior consists of only two files (HTML and JS), creates no special folders, and doesn't make any changes to the menus. The materials list is simple:
Collecting Materials for a Multifile Extension: Custom Horizontal Rule Object (Chapter 3, Workshop #3, and Chapter 6, Workshop #2)The list of materials to assemble for this extension includes the following:
Figure C.1 shows the collection folder for this extension. Figure C.1. The files comprising the Custom Horizontal Rule object, assembled in a collection folder and ready for packaging.
Collecting Materials for an Extension with Menu Changes: Table Helper Floating Panel (Chapter 7, Workshop #1)This extension consists of only one file, so that part of the job is easy. But the checklist of materials also includes the menu changes:
<menuitem name="Rest_ore All" id="DWMenu_Window_RestoreAll" /> add this: <separator /> <menuitem name="Table Helper" enabled="true" command="dw.toggleFloater('TableHelper')" checked="dw.getFloaterVisibility('TableHelper')" id="RocketLaura_TableHelper_Floater"/> Task 2: Create the MXI (instructions) file This is the most painstaking part of the packaging process. The package requires an XML file, with the extension .mxi, containing instructions on where to put files, how to change menus, and what folders to create; as well as information on what the extension is supposed to do, who its author is, and so forth. The XML syntax for this file is very exacting. Saving the MXI FileThe installer file is simply an XML file saved with the .mxi extension. Its filename, however, must be valid on both Windows and Macintosh platforms, and can have no spaces. It can be saved anywhere on your hard drive, but because all pathnames to the extension files must be relative to the MXI file, it makes the most sense to save it in the collection folder with your other extension files. Structure of an MXI FileLucky for you, the Macromedia Extension Manager comes with detailed documentation, a sample file, and a blank template file to use in creating the MXI document. To find them, locate the application folder for the Extension Manager on your computer, and look inside. Inside the Samples/Dreamweaver subfolder, you see the following:
The contents of Sample.mxi, a simple but properly structured MXI file, are shown here: <macromedia-extension name="Hello, World" version="1.0" type="Command"> <! List the required/compatible products > <products> <product name="Dreamweaver" version="3" primary="true" /> </products> <! Describe the author > <author name="Macromedia" /> <! Describe the extension > <description> <![CDATA[ This is a sample extension.<br><br> It displays a javascript alert that says "Hello, World!". ]]> </description> <! Describe where the extension shows in the UI of the product > <ui-access> <![CDATA[ Access from the 'Hello, World' entry in the Commands menu. ]]> </ui-access> <! Describe the files that comprise the extension > <files> <file name="Sample.htm" destination="$dreamweaver/configuration/commands" /> </files> <! Describe the changes to the configuration > <configuration-changes> <! Add an entry to the commands menu > <menu-insert insertAfter="DWMenu_Commands_SortTable" skipSeparator="true"> <menuitem name="Hello, World" file="Commands/Sample.htm" id="Sample_HelloWorld" /> <separator id="Sample_HelloWorld_Separator" /> </menu-insert> </configuration-changes> </macromedia-extension> Unfortunately, both Sample.mxi and Blank.mxi are limited in only providing options for relatively simple extensions. Tables C.1 through C.16 provide more detailed specifications for the possible contents of the MXI file, along with syntax requirements. Use these tables in conjunction with the Blank.mxi template to construct your instruction file. note Note that the tables do not present an exhaustive list of elementsthey cover only those elements used for creating extension types covered in this book. A much more detailed set of instructions and syntax requirements is available in PDF form on the Macromedia Exchange Web site (http://www.macromedia.com/exchange/dreamweaver). Table C.1 describes <macromedia-extension> , which is the main tag for extension installation files. Table C.1. MXI File: <macromedia-extension>
Table C.2 describes <products> . This tag is the container for one or more <products/> tags. Table C.2. MXI File: <products>
Table C.3 describes <product /> . Each instance of this tag specifies a Macromedia product(s) with which the extension is compatible. At least one <product/> tag must be defined. Table C.3. MXI File: <product />
Table C.4 describes <author /> , which contains the extension author's name. This information will appear in the Extension Manager window. Table C.4. MXI File: <author />
Table C.5 shows <description> . This tag describes what the extension does or is used for. This information will appear in the Extension Manager window. Table C.5. MXI File: <description>
Table C.6 describes <ui-access> . This tag specifies where to find the extension in the Dreamweaver user interface. This information will appear in the Extension Manager window. Table C.6. MXI File: <ui-access>
Table C.7 describes <files> , which is the container for one or more <file/> tags. Table C.7. MXI File: <files>
Table C.8 describes <file /> . Each instance of this tag provides information about a specific file to be installed as part of the extension. Table C.8. MXI File: <file />
Table C.9 describes <configuration-changes> . This tag is the container for tags specifying changes to menus, shortcuts, server behaviors, server formats, and data sources. Table C.9. MXI File: <configuration-changes>
Table C.10 describes <menu-remove /> . Each instance of this tag specifies a menu bar, menu, menu item, or format to remove from the interface. Table C.10. MXI File: <menu-remove />
Table C.11 describes <menu-insert > . Each instance of this tag specifies where to insert a menu bar, menu, menu item, or format. Table C.11. MXI File: <menu-insert >
Table C.12 describes <shortcut-remove /> . Each instance of this tag specifies a keyboard to remove from the menus.xml file. Table C.12. MXI File: <shortcut-remove />
Table C.13 describes <shortcut-insert > . Each instance of this tag specifies a keyboard shortcut to be added to a particular location in the menus.xml file. Table C.13. MXI File: <shortcut-insert >
*See the discussion on menus.xml entries in Chapter 7 for details of how to format shortcuts. Table C.14 describes <ftp-extension-map-changes> . This container tag specifies a change to the FTPExtensionMap.txt file. (This file defines whether the file is downloaded/uploaded to an FTP server as ASCII or binary.) Table C.14. MXI File: <ftp-extension-map-changes>
Table C.15 describes < ftp-extension-remove /> . This tag specifies the extension to be removed from the SourceFormat.txt file. Table C.15. MXI File: < ftp-extension-remove />
Table C.16 describes <ftp-extension-insert /> . This tag specifies a change to the FTPExtensionMap.txt file. Table C.16. MXI File: <ftp-extension-insert />
The following is an alternate blank MXI template file, including many more specialized options that can be used in place of Blank.mxi. <!remove this comment for each tag attribute, assign a value or remove the attribute> <!remove this comment not all tags will be required for all extensions some tags may be present more than once for a given extension> <macromedia-extension name version type requires-restart> <products> <product name version primary required /> </products> <author name /> <description> <![CDATA[ <!remove this comment and add your descriptive text here> ]]> </description> <ui-access> <![CDATA[ <!remove this comment and add user access information here> ]]> </ui-access> <files> <file name destination platform shared systemfile winextension/> </files> <configuration-changes> <menu-remove id /> <menu-insert insertAfter insertBefore appendTo prependTo skipSeparator> <menu name id platform> <menuitem name id key platform file command enabled checked dynamic arguments /> </menu> </menu-insert> <shortcut-remove id> <shortcut-insert listId> <shortcut key id command file platform /> </shortcut-insert> <ftp-extension-map-changes> <ftp-extension-insert extension type mac-creator macfile-type /> <ftp-extension-remove extension /> </ftp-extension-map-changes> </configuration-changes> </macromedia-extension> note You can download the alternate blank template shown above from the book's companion web site, www.newriders.com. Creating a Simple MXI: Set Page Properties BehaviorWith all the above resources to work from, creating this installation file shouldn't be too difficult. An example of what the completed MXI file might look like is shown as follows. In particular, take note of the following:
<macromedia-extension name="Set Page Properties" version="1.0" type="behavior" requires-restart="true"> <products> <product name="Dreamweaver" version="6" primary="true" /> </products> <author name="RocketLaura" /> <description> <![CDATA[ Create a JavaScript that lets page visitors change page and text colors.<br> All default page, text, link colors can be specified. ]]> </description> <ui-access> <![CDATA[ Access from the Behaviors menu. ]]> </ui-access> <files> <file name="Set Page Properties.htm" destination="$dreamweaver/configuration/ behaviors/actions" /> <file name="Set Page Properties.js" destination="$dreamweaver/configuration/ behaviors/actions" /> </files> </macromedia-extension> Creating an MXI for a Multifile Extension: Custom Horizontal Rule ObjectAn example of what the MXI file for this extension might look like is shown as follows. In particular, note the various <file> entries. Note the following:
<macromedia-extension name="Custom Horizontal Rule" version="1.0" type="object" requires-restart="true"> <products> <product name="Dreamweaver" version="4" primary="true" required="true" /> </products> <author name="RocketLaura" /> <description> <![CDATA[ This object inserts a horizonatal rule, with an insertion dialog box for setting attributes, and an inspector that displays the color attribute. <br><br> ]]> </description> <ui-access> <![CDATA[ Access from the My Stuff category of the Insert bar. ]]> </ui-access> <files> <file name="objects/Custom HR.htm" destination="$dreamweaver/configuration/objects/My Stuff" /> <file name="objects/Custom HR.js" destination="$dreamweaver/configuration/objects/My Stuff" /> <file name="inspectors/Custom HR.htm" destination="$dreamweaver/configuration/inspectors" /> <file name="inspectors/customhr.gif" destination="$dreamweaver/configuration/inspectors" /> </files> </macromedia-extension> Creating an MXI for an Extension with Menu Changes: Table Helper Floating PanelAn example of what the installer file for the Table Helper might look like is shown as follows. In particular, pay attention to the following:
<macromedia-extension name="Table Helper" version="1.0" type="floater" requires-restart="true"> <products> <product name="Dreamweaver" version="4" primary="true"/> <product name="UltraDev"/> </products> <author name="RocketLaura" /> <description> <![CDATA[ This panel provides comprehensive information about the cell dimensions and structure of a selected table. ]]> </description> <ui-access> <![CDATA[ Access from the 'Table Helper' entry in the Window menu. ]]> </ui-access> <files> <file name="TableHelper.htm" destination="$dreamweaver/configuration/floaters" / > </files> <configuration-changes> <menu-insert insertAfter="DWMenu_Window_RestoreAll"> <menuitem name="Table Helper" id="RocketLaura_TableHelper_Floater" command="dw.toggleFloater('TableHelper')" enabled="true" checked="dw.getFloaterVisibility( 'TableHelper')" /> </menu-insert> </configuration-changes> </macromedia-extension> note It's important to understand what's happening in the MXI file. If you don't want to spend time hand-coding every MXI file you need, try out Public Domain's MXI File Creator extension, available from the Macromedia Dreamweaver Exchange. This extension creates a Dreamweaver command that allows you to enter all the relevant information for your MXI file (in plain old English) and then writes the MXI file for you. Task 3: Package the Extension Into an MXP (Installer) File After you've assembled all your bits and pieces into the folder you've designated as your staging area, and you've created the MXI file with instructions for turning those pieces into an extension, it's time to create the installer package. Follow these steps:
|