createAnnouncement(title, html, parent)
已淘汰。此函式已淘汰,不應在新的指令碼中使用。
建立新公告
參數
名稱 | 類型 | 說明 |
title | String | 要建立的公告頁面標題 |
html | String | 網頁的 HTML 內文 |
parent | Page
| 上層頁面 |
回攻員
Page
:建立的 Page
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://sites.google.com/feeds
createAnnouncementsPage(title, name, html)
已淘汰。此函式已淘汰,不應在新的指令碼中使用。
建立新的公告頁面。請注意,單一上層網站或網頁最多只能有 500 個子頁面。
// This method can be called from both a Site instance
// as well as a Page instance
var site = SitesApp.getSite("example.com", "mysite");
var page = site.getChildren()[0];
site.createAnnouncementsPage("New Announcement",
"new-announcement",
"<h1>Your announcement goes here</h1>");
page.createAnnouncementsPage("New Announcement",
"new-announcement-child",
"<h1>Your announcement goes here</h1>");
參數
名稱 | 類型 | 說明 |
title | String | 網頁標題 |
name | String | 網頁名稱 |
html | String | 網頁內容 |
回攻員
Page
:新建立的 Page
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://sites.google.com/feeds
createFileCabinetPage(title, name, html)
已淘汰。此函式已淘汰,不應在新的指令碼中使用。
建立新的檔案櫃頁面。請注意,單一上層網站或網頁最多只能有 500 個子網頁。
// This method can be called from either a site or a page.
var site = SitesApp.getSite("example.com", "mysite");
var page = site.getChildren()[0];
site.createFileCabinetPage("New File Cabinet",
"new-file-cabinet",
"<h1>Your HTML here</h1>");
page.createFileCabinetPage("New File Cabinet",
"new-file-cabinet-child",
"<h1>Your HTML here</h1>");
參數
名稱 | 類型 | 說明 |
title | String | 網頁標題 |
name | String | 網頁名稱 |
html | String | 網頁內容 |
回攻員
Page
:新建立的 Page
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://sites.google.com/feeds
createListItem(html, columnNames, values, parent)
已淘汰。此函式已淘汰,不應在新的指令碼中使用。
已淘汰,已由 Page
上的 createListItem 取代。
建立新的 ListItem。
參數
名稱 | 類型 | 說明 |
html | String | 項目內容 - 無意義且毀損 |
columnNames | String[] | 欄名 (非必要) |
values | String[] | 資料欄的值 |
parent | Page
| ListPage 父項 |
回攻員
ListItem
:用於鏈結的 ListItem
。
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://sites.google.com/feeds
createListPage(title, name, html, columnNames)
已淘汰。此函式已淘汰,不應在新的指令碼中使用。
建立新的清單頁面。請注意,上層網站或網頁最多只能有 500 個子網頁。
// This method can be called from either a site or a page.
var site = SitesApp.getSite("example.com", "mysite");
var page = site.getChildren()[0];
site.createListPage("New List Page",
"new-list-page",
"<h1>Your List Page HTML here</h1>",
[ "col1", "col2" ]);
page.createListPage("New List Page",
"new-list-page-child",
"<h1>Your List Page HTML here</h1>",
[ "col1", "col2" ]);
參數
名稱 | 類型 | 說明 |
title | String | 網頁標題 |
name | String | 網頁名稱 |
html | String | 網頁內容 |
columnNames | String[] | 用於清單的資料欄名稱 |
回攻員
Page
:新建立的 Page
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://sites.google.com/feeds
createPageFromTemplate(title, name, template)
已淘汰。此函式已淘汰,不應在新的指令碼中使用。
使用範本建立新頁面。請注意,單一上層網站或網頁最多只能有 500 個子頁面。
// This method can be called from either a site or a page.
var site = SitesApp.getSite("example.com", "mysite");
var template = site.getTemplates()[0];
// If an invalid template is passed, this will throw an "Invalid Argument" error.
site.createPageFromTemplate("ClonedPage", "cloned-page", template);
參數
名稱 | 類型 | 說明 |
title | String | 網頁標題 |
name | String | 網頁名稱 |
template | Page
| 範本頁面 |
回攻員
Page
:新建立的 Page
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://sites.google.com/feeds
createWebAttachment(title, url, parent)
已淘汰。此函式已淘汰,不應在新的指令碼中使用。
已淘汰,在 Page
中已由 createWebAttachment 取代。
建立新的網路附件。
參數
名稱 | 類型 | 說明 |
title | String | 附件標題 |
url | String | 附件的網址 |
parent | Page
| 上層頁面 |
回攻員
Attachment
— 這是用於鏈結的附件。
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://sites.google.com/feeds
createWebPage(title, name, html)
已淘汰。此函式已淘汰,不應在新的指令碼中使用。
建立新網頁。請注意,上層網站或網頁最多只能有 500 個子網頁。
// This method can be called from either a site or a page.
var site = SitesApp.getSite("example.com", "mysite");
var page = site.getChildren()[0];
site.createAnnouncementsPage("New Announcement",
"new-announcement",
"<h1>Your announcement goes here</h1>");
page.createAnnouncementsPage("New Announcement",
"new-announcement-child",
"<h1>Your announcement goes here</h1>");
參數
名稱 | 類型 | 說明 |
title | String | 網頁標題 |
name | String | 網頁名稱 |
html | String | 網頁內容 |
回攻員
Page
:新建立的 Page
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://sites.google.com/feeds
getAllDescendants(options)
已淘汰。此函式已淘汰,不應在新的指令碼中使用。
取得包含選用進階引數的子系頁面陣列。
var site = SitesApp.getSite("example.com", "mysite");
var descendants = site.getAllDescendants({
type: SitesApp.PageType.WEB_PAGE,
start: 0,
max: 25,
includeDrafts: false,
includeDeleted: true,
search: "target"
});
for(var i in descendants) {
Logger.log(descendants[i].getName());
}
參數
名稱 | 類型 | 說明 |
options | Object | 下方「進階引數」一節中定義的 JavaScript 物件欄位 |
進階參數
名稱 | 類型 | 說明 |
type | PageType[]
| 只取得這類網頁 |
start | Integer | 由此開始結果 |
max | Integer | 結果數量上限 (預設為 200) |
includeDrafts | Boolean | 是否要包含草稿頁面 (預設為 false) |
includeDeleted | Boolean | 是否要納入已刪除的網頁 (預設為 false) |
search | String | 只傳回與這項查詢相符的網頁 |
回攻員
Page[]
:屬於指定類型的直接和間接子網頁陣列
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://sites.google.com/feeds
getAnnouncementsPages()
已淘汰。此函式已淘汰,不應在新的指令碼中使用。
擷取指定 Google 網站的公告網頁清單。
var site = SitesApp.getSite("example.com", "mysite");
var pages = site.getAnnouncementsPages();
for(var i in pages) {
Logger.log(pages[i].getTitle());
}
回攻員
Page[]
:Page
執行個體的陣列
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://sites.google.com/feeds
getChildren(options)
已淘汰。此函式已淘汰,不應在新的指令碼中使用。
取得子頁面的陣列,以及選用的進階引數。
var site = SitesApp.getSite("example.com", "mysite");
var childPages = site.getChildren({
type: SitesApp.PageType.WEB_PAGE,
start: 0,
max: 25,
includeDrafts: false,
includeDeleted: true,
search: "target"
});
for(var i in childPages) {
Logger.log(childPages[i].getName());
}
參數
名稱 | 類型 | 說明 |
options | Object | 下方「進階引數」一節中定義的 JavaScript 物件欄位 |
進階參數
名稱 | 類型 | 說明 |
type | PageType[]
| 只取得這類網頁 |
start | Integer | 由此開始結果 |
max | Integer | 結果數量上限 (預設為 200) |
includeDrafts | Boolean | 是否要包含草稿頁面 (預設為 false) |
includeDeleted | Boolean | 是否要納入已刪除的網頁 (預設為 false) |
search | String | 只傳回與這項查詢相符的網頁 |
回攻員
Page[]
:特定類型的直接子網頁陣列
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://sites.google.com/feeds
getFileCabinetPages()
已淘汰。此函式已淘汰,不應在新的指令碼中使用。
擷取指定 Google 網站的「檔案櫃」頁面清單。
var site = SitesApp.getSite("example.com", "mysite");
var pages = site.getFileCabinetPages();
for(var i in pages) {
Logger.log(pages[i].getTitle());
}
回攻員
Page[]
:Page
執行個體的陣列
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://sites.google.com/feeds
getListPages()
已淘汰。此函式已淘汰,不應在新的指令碼中使用。
擷取指定 Google 網站的網站清單網頁清單。
var site = SitesApp.getSite("example.com", "mysite");
var pages = site.getListPages();
for(var i in pages) {
Logger.log(pages[i].getTitle());
}
回攻員
Page[]
:Page
執行個體的陣列
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://sites.google.com/feeds
getWebPages()
已淘汰。此函式已淘汰,不應在新的指令碼中使用。
擷取指定 Google 網站的網頁清單。
var site = SitesApp.getSite("example.com", "mysite");
var pages = site.getWebPages();
for(var i in pages) {
Logger.log(pages[i].getTitle());
}
回攻員
Page[]
:Page
執行個體的陣列
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://sites.google.com/feeds
search(query, options)
已淘汰。此函式已淘汰,不應在新的指令碼中使用。
取得與搜尋查詢相符的子系網頁陣列,以及選用的進階引數。
var site = SitesApp.getSite("example.com", "mysite");
var childPages = site.getChildren({
type: SitesApp.PageType.WEB_PAGE,
start: 0,
max: 25,
includeDrafts: false,
includeDeleted: true,
search: "target"
});
for(var i in childPages) {
Logger.log(childPages[i].getName());
}
參數
名稱 | 類型 | 說明 |
query | String | 要比對的完整文字搜尋查詢 |
options | Object | 下方「進階引數」一節中定義的 JavaScript 物件欄位 |
進階參數
名稱 | 類型 | 說明 |
type | PageType[]
| 只取得這類網頁 |
start | Integer | 由此開始結果 |
max | Integer | 結果數量上限 (預設為 200) |
includeDrafts | Boolean | 是否要包含草稿頁面 (預設為 false) |
includeDeleted | Boolean | 是否要納入已刪除的網頁 (預設為 false) |
回攻員
Page[]
:屬於指定類型的直接和間接子網頁陣列
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://sites.google.com/feeds
setTheme(theme)
已淘汰。此函式已淘汰,不應在新的指令碼中使用。
設定網站主題
主題必須是有效的主題字串。如果是詳盡清單,請編寫測試方法,並將無效的值傳遞至 setTheme()。指令碼會擲回 Service 錯誤,並傳回可用主題的完整清單。您也可以在「管理網站」->「主題」下找到可用的主題清單。主題名稱字串在小寫的情況下,通常與「主題」頁面中的主題名稱相同,但會移除空格和特殊字元。例如,「Terra:Water」(水域) 的字串會是「terrawater」。
var site = SitesApp.getSite("example.com", "mysite");
// All of the setter methods return the site instance so setters
// can be chained
site.setTitle("My Site")
.setSummary("This is my site")
.setTheme("simple");
參數
名稱 | 類型 | 說明 |
theme | String | 要為此 Site 設定的主題字串名稱 |
回攻員
Site
:方法鏈結的網站
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://sites.google.com/feeds