Class Comment

Comment

A Comment attached to any Sites page.

Methods

MethodReturn typeBrief description
deleteComment()voidDeletes this comment.
getAuthorEmail()StringGets the email address of the author of this comment.
getAuthorName()StringGets the name of the author of this comment.
getContent()StringReturn the content of this comment as a String.
getDatePublished()DateReturn the date this comment was originally published.
getLastUpdated()DateReturn the date this comment was last updated.
getParent()PageGet the parent page of this comment.
setContent(content)CommentSet the content of this comment.
setParent(parent)CommentSet the parent page of this comment.

Detailed documentation

deleteComment()

Deletes this comment.

var pages = SitesApp.getSite('example.com', 'mysite').getChildren();
var comments = pages[0].getComments();

// Let's delete all of Eric's comments
for(var i = 0; i < comments.length; i++) {
  if(comments[i].getAuthorEmail() == "eric@example.com") {
    comments[i].deleteComment();
  }
}

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://sites.google.com/feeds

getAuthorEmail()

Gets the email address of the author of this comment.

Return

String — the author's email

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://sites.google.com/feeds

getAuthorName()

Gets the name of the author of this comment.

var pages = SitesApp.getSite('example.com', 'mysite').getChildren();
var comments = pages[0].getComments();
var comment = comments[0];
var authorEmail = comment.getAuthorEmail();

Return

String — the author's name

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://sites.google.com/feeds

getContent()

Return the content of this comment as a String.

var pages = SitesApp.getSite('example.com', 'mysite').getChildren();
var comments = pages[0].getComments();
var content = comments[0].getContent()

Return

String — the comment content

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://sites.google.com/feeds

getDatePublished()

Return the date this comment was originally published.

var pages = SitesApp.getSite('example.com', 'mysite').getChildren();
var comments = pages[0].getComments();
var date = comments[0].getDatePublished();

Return

Date — the date of original publication

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://sites.google.com/feeds

getLastUpdated()

Return the date this comment was last updated.

var pages = SitesApp.getSite('example.com', 'mysite').getChildren();
var comments = pages[0].getComments();
var date = comments[0].getLastUpdated();

Return

Date — the last updated date

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://sites.google.com/feeds

getParent()

Get the parent page of this comment.

var pages = SitesApp.getSite('example.com', 'mysite').getChildren();
var comments = pages[0].getComments();
var comment = comments[0];

// parentPage should be the same page as pages[0]
var parentPage = comment.getParent();

Return

Page — the parent page

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://sites.google.com/feeds

setContent(content)

Set the content of this comment.

var pages = SitesApp.getSite('example.com', 'mysite').getChildren();
var comments = pages[0].getComments();
var comment = comments[0];
 comment.setContent("New Content");

// Note that this returns a Comment, so you can chain the method calls
var updatedContent = comment.setContent("New Content")
                            .getContent();

Parameters

NameTypeDescription
contentStringthe new content

Return

Comment — this Comment for chaining

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://sites.google.com/feeds

setParent(parent)

Set the parent page of this comment.

var pages = SitesApp.getSite('example.com', 'mysite').getChildren();
var comments = pages[0].getComments();
var comment = comments[0];

// Let's say we want to move the comment to its parent's next neighbor ..
// This will only work if the example site has multiple children
var newParentPage = comment.setParent(pages[1]).getParent();

Parameters

NameTypeDescription
parentPagethe new parent

Return

Comment — this Comment for chaining

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://sites.google.com/feeds

Enviar comentarios sobre…

¿Necesitas ayuda? Visita nuestra página de asistencia.