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 |
| 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. |
| 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" or "Plain Text" depending on the editor mode set for this page. |
| 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. |
| raw |
Boolean |
read/write |
True if the "Raw" setting is checked in Page Properties. If True, EditMe serves this page without a Layout. |
| 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. |
| versions |
Array of Pages |
read | Returns an array of all versions of this page. |
Functions
| Name | Return Type |
Description |
| 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. |
| save() |
none |
Saves changes to this page object. |
| 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 Java Script API