beautypg.com

Adobe Extending Dreamweaver CS4 User Manual

Page 299

background image

293

EXTENDING DREAMWEAVER CS4

Data sources

For the MyDatasource Variable, you want Dreamweaver to insert the ColdFusion code

#MyXML.variable#

where variable is the value the user wants from the data source.

1

Create a new blank file.

2

Enter the following:


3

Save the file as MyDatasource_DataRef.edml in the Configuration/DataSources/ColdFusion folder.

Creating the JavaScript file that implements the data sources API functions

After you have defined the name of the data source, the name of the supporting script files, and the code for the
working Dreamweaver document, you need to specify the JavaScript functions for Dreamweaver to provide the user
with the ability to add, insert, and delete the necessary code into a document.

Based on the construction of the Cookie Variable data source, you can implement the MyXML data source, as shown
in the following example. (The

MyDatasource

_

Variable

command used in the

addDynamicSource()

function is

defined in

Creating the supporting command files for user input

” on page 295.)

1

Create a new blank file.

2

Enter the following:

//************** GLOBALS VARS *****************

var MyDatasource_FILENAME = "REQ_D.gif";
var DATASOURCELEAF_FILENAME = "DSL_D.gif";

//****************** API **********************
function addDynamicSource()
{

MM.retVal = "";
MM.MyDatasourceContents = "";
dw.popupCommand("MyDatasource_Variable");
if (MM.retVal == "OK")
{

var theResponse = MM.MyDatasourceContents;
if (theResponse.length)
{

var siteURL = dw.getSiteRoot();
if (siteURL.length)
{

dwscripts.addListValueToNote(siteURL, "MyDatasource", theResponse);

}
else
{

alert(MM.MSG_DefineSite);

}

}
else

This manual is related to the following products: