Using Templates - Adobe GoLive CS2 Programmer's Manual

Hide thumbs Also See for GoLive CS2:
Table of Contents

Advertisement

SDK Programmer's Guide
When the method returns, the Untitled.html file exists on disk and appears in the Site window.
The webSite methods that create a file or a folder return a
the newly created item. You can use this object to work with a new file immediately. For example:
var mySiteRef = webSite.createFile("Untitled.html");
if (mySiteRef.openDocument())
{
document.view = "layout";
var bod = document.documentElement.getSubElement("body");
bod.layout.insertBox("img")
...
}
By default, webSite methods append a numeric suffix to the new file or folder's name when it is not
unique. For example, this creates the New and New1 folders in the root folder of the site:
var mySiteRef = website.createFolder("New");
var myOtherSiteRef = website.createFolder("New");
To suppress this behavior and overwrite same-named files or folders with new ones, pass false for the
optional fixDuplicateNames argument:
var newFileRef = website.createFile("myFile", false); // overwrite existing
When you pass paths to these methods, they attempt to create folders as necessary to implement the
directory structure the path specifies. For example, the following code puts two new folders and a file into
the New folder:
var aSiteRef = website.createFile("New/Newer/Newest/aFile.html");
When these methods return, the Site window displays the hierarchical path to the new file or folder, and
the newly created item is selected. To suppress this behavior and display a collapsed view in the Site
window, pass false for the optional show argument:
website.createFile("New/Newer/Newest/aFile.html", true, false);
website.createFolder("Grand/Parent/Child/", true, false);

Using templates

For convenience, you can also create files from templates and stationery.
// create from template
var path = website.document.file.parent.url +
var ary = templateFolder.getFiles("*.html");
website.createFileFromTemplate("newTpl.html", ary[0].url);
// create from stationery
var path = website.document.file.parent.url +
var ary = templateFolder.getFiles("*.html");
website.createFileFromStationery("newStat.html", ary[0].url);
Adobe GoLive CS2 SDK
website.document.site.name +
".data\/Template\/";
website.document.site.name +
".data\/Stationery\/";
siteReference Object
that provides access to
Managing Web Sites
138

Advertisement

Table of Contents
loading

Table of Contents