JavaScript API

Welcome

Login to contribute. Register if you haven't yet.

Support Options

1. Search this site.
2. Make or vote for a Suggestion.
3. Post to Community Support.
3. Contact EditMe Support staff.

Stay Informed

Keep informed of product changes, tutorials and tips via EditMe's Blog and monthly newsletter.

JavaScript API Class: Page

An instance of the Page class represents one version of a page. You can access the current page in a script using the "page" implicit object, or get an instance of any other page using "site.getPage('PageName')".

Properties

Name  Type  Access
Description 
allowRelations boolean read/write The "Allow Child Modification" page property. See the description of this property at Advanced Page Properties.
attachments
Array of Attachments
read
An array of Attachment objects associated with page.
canAttach Boolean
read
True if the current user has sufficient access to upload attachments to this page.
canComment
Boolean
read
True if the current user has sufficient access to post comments to this page.
canEdit
Boolean
read
True if the current user has sufficient access to edit this page.
children Array of Pages read Returns an array of this page's child pages. These page objects are stubs and do not have all content properties populated. See Page Relationships: the Organize tab.
className String read Returns "Page" - this can be used to determine the object type when it is unknown.
comments
Array of Comments
read
An array of Comment objects associated with page.
commentsDisabled
Boolean
read/write
True if comments are disabled for this page.
content
String
read/write
The content of this page.
date
Date
read The date this version was created. Current user's time zone is applied.
deleted
Boolean
read/write True if this page is marked as deleted.
description
String
read/write
The change description for this version of the page.
document
DOM4J Document read
An XML Document object representing the content of this page. This property causes an error if called on a Page that doesn't have one of the XML-JS EditMe MIME types.
editorMode
String
read/write Returns "Rich Text", "Code" or "Plain Text" depending on the editor mode set for this page.
excerpt String read/write The Excerpt field from the Properties tab of the editing screen. See Page Properties.
exists
Boolean
read
True if a page with this name exists.
hidden
Boolean
read/write
True if this page is marked as hidden in Page Properties.
isScript Boolean
read True if this page is one of the XML-JS MIME types in Page Properites (Layout or Page Script). If this is False, the page cannot be passed to the process layout command.
mimeType
String
read/write
The MIME type set in Page Properties.
name
String
read/write

The name of the page. The name is used in the URL to access the page and is also a unique identifier in combination with the version number.

Note that setting the page name here does not rename an existing page - it merely changes the name associated with this page object, such that upon save a new page will be created if the name doesn't exist, or a new version of the existing page with that name will be created. 

pageDate Date read/write The Page Date field from the Properties tab of the editing screen. This is an arbitrary date value associated with the page. See Page Properties.
parents Array of Pages read Returns an array of this page's parents as specified in the Organize tab of the editing screen. These page objects are stubs and do not have all content properties populated. See Page Relationships: the Organize tab.
raw
Boolean
read/write
True if the "Raw" setting is checked in Page Properties. If True, EditMe serves this page without a Layout.
redirect String read/write The Redirect field of the Page Properties tab of the editing screen. See Page Properties.
readOnly  Boolean
read/write
True if the page object represents an EditMe internal page, such as the Index or Search page. This property is used in run-time and is not saved.
security  PageSecurity
read  The setting and prolicy properties of the object stored by this property are writable. See the PageSecurity class for details.
title
String
read/write The page title set in the Edit screen.
titleOrName
String
read
A shorcut property that returns the title if it is not blank or the name if there is no title set. If the page name is returned, any camel case will be spaced out, such that MyPage becomes My Page.
user
String
read/write
The name of the user that created this version of the page.
version
Number
read
The number of this version of the page. Version numbers start at 1 for each page name.
versionChildren String read Changing a page's children creates a new version. This property can be used to see how page relationships have changed across multiple page versions. The property returns a string of page names separated with spaces. The order of these is specific to the order set in the Organize tab of the page editing tool. See Page Relationships: the Organize tab.
versions
Array of Pages
read  Returns an array of all versions of this page.

Functions

Name  Return Type
Description 
addChild(page) none Adds the specified page (which can be a page object or a string containing a page name) to this page's list of children. The child page will be added to the end of the current list of child pages. To specify an specific order for child pages, use the overwriteChildren(String) function. To manage parent relationships, get the appropriate parent page and call this method on that object.
getCanAttach(user)
Boolean
True if the specified user can upload attachments to this page. Use the page.canAttach property to test access for the current user.
getCanComment(user) Boolean
True if the specified user can comment on this page. Use the page.canComment property to test access for the current user.
getCanEdit(user) Boolean True if the specified user can edit this page. Use the page.canEdit property to test access for the current user.
getCanView(user)
Boolean True if the specified user can view this page. Use the page.canView property to test access for the current user.
getComment(Number)  Comment Returns a comment with the specified ID. Returns null if a comment with the specified ID does not exist.
newComment() Comment Creates and returns a blank Comment object for this page. The Comment is not actually created until comment.save() is called.
overwriteChildren(String) none Use this function to set all the child pages for the current page. The String value must contain page names separated by a space character. The order of names is maintained. An empty string will remove all child pages. You can get the current child pages in the format this function expects from the versionChildren property. This function versions the page - there is no need to call save() afterwords.
removeChild(page) none Removes the specified child page relationship. The page argument can be either a Page object or a string containing a page name. To manage parent relationships, get the appropriate parent page and call this method on that object.
save()
none
Saves changes to this page object.
testCanEdit()
testCanEdit(user)
Boolean True if the current or specified user can edit the page based on the security currently set. Unlike getCanEdit(), does not require the page to have a valid name or to even exist. Provides a way to test various security settings without having a page implementing them.
testCanView()
testCanView(user)
Boolean See testCanEdit(). Same purpose and function, but tests view instead of edit access.
toString()
String
Returns the equivalent of page.name

Example

function getLastChangeDescription (pageName) {
    var mypage = site.getPage(pageName);
    if (mypage.exists) {
        return mypage.description;
    } else {
        return 'Error: Page does not exists';
    }
}

 

Return to JavaScript API