Undocumented Dreamweaver: dw.loadString()
Posted Saturday, March 05, 2005 7:08:20 PM by Danilo Celic
Many times you'll need access to similar messages that you present to the user, whether in alerts for errors, or in notes on dialogs in a Dreamweaver extension. You could include the same text over and over again, in all of the extensions you have as part of your project, or you could write your own custom file manipulation functions that would share a common file to store your common text. Well, the great folks that bring you Dreamweaver also thought of this second method, they just happened to not document it just yet, and it's called dreamweaver.loadString().
Essentially, the loadString method takes as a parameter, an identifying ID that identifies the particular string that you're trying to use within your extension. Well, what does that mean? Ok, here's a code snippet to test out using Tom's JavaScript Eval panel:
alert(dw.loadString('General/docEncoding'));
On my system, I get alerted: iso-8859-1
So, where, and how do you store your strings so that that you can load them when needed?
As usual, you need to get into the Dreamweaver configuration folder. Go to the Configuration/Strings/ folder. You store your data in a specially formatted XML file. See the following code for an example of the format:
<strings>
<string id="uniqueIdentifier" value="string to store">
</strings>
You can have multiple <string> tags within the parent <strings> tag.
Make sure that you uniquely identify your strings, preferably by "scoping" the strings by including your company name, or your initials, and also save your strings XML file with a unique name inside the Strings folder. All this is to avoid any naming conflict with other developers, or with built in stings, and strings XML files.
Category tags: Dreamweaver, Extensibility, JavaScript
Posted by Danilo Celic
Add comment |
View comments (1) |
Permalink
|
Trackbacks (0)
|
Digg This
See Community MX content by Danilo Celic


Blog RSS feed













