Apps脚本添加指向Google网站的链接

Apps脚本添加指向Google网站的链接

本文介绍了您如何通过Google Apps脚本添加指向Google网站的链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在编写脚本,通过动态创建页面来简化Google网站的管理。我希望能够创建一个包含指向这些页面的链接的目录。



所以我在想......像是......

  var page = site.getChildByName(NEW URL); 
var link = [page.getUrl()];
page = site.getChildByName(URL TO DIRECTORY)。addListItem(link);

...使用Google应用程式脚本。到目前为止还没有完全测试过这个,但是它还没有能够让链接在列表中工作。我希望只保留页面模板作为一个普通的网页。

如果我去那条路线,编辑html是唯一的选择吗?希望有一个更简单的方法。



任何想法都会很棒。

解决方案

这是一个小测试,显示您网站中所有页面的列表

 函数doGet(){
var app = UiApp.createApplication()。setTitle(本网站的目录)
var mainPanel = app.createAbsolutePanel()。setStyleAttributes({background:'beige',padding:'20px'});
var scroll = app.createScrollPanel()。setPixelSize(450,300);
var site = SitesApp.getSiteByUrl('https://sites.google.com/site/appsscriptexperiments/')
var pages = site.getAllDescendants()
var grid = app.createGrid (pages.length,2).setWidth(400)
(n = 0; n grid.setText(n,0,pages [n])。 getName())。setWidget(n,1,app.createAnchor('open',pages [n] .getUrl()))
}
app.add(mainPanel.add(scroll.add(格)))
返回应用程序
}

我想你知道ho在您的网站页面中使用它,但仅供其他人使用:您必须前往管理站点>脚本应用>创建新脚本>保存版本>使用适当的授权部署 最后返回到你的页面,并将它作为一个小工具插入(更好的边框和大小为450x300,个人pov ^^)。您也可以将其作为独立的webapp使用其部署网址。




I have been scripting a few ways to make my Google site easier to manage by dynamically creating pages. I want to be able to create a directory with links to those pages.

So i was thinking something like...

var page = site.getChildByName("NEW URL");
var link = [page.getUrl()];
page = site.getChildByName("URL TO DIRECTORY").addListItem(link);

...using google apps scripts. Haven't tested this too thoroughly as of yet but it haven't been able to get the links to work in the list. I was hoping to just keep the page template as a normal webpage.

If I went that route would editing the html be the only option? Hopefully there is an easier way.

Any ideas would be great. Thanks!

解决方案

here is a small test that shows a list of all the pages in your site

function doGet() {
  var app=UiApp.createApplication().setTitle("Directory of this site")
  var mainPanel = app.createAbsolutePanel().setStyleAttributes({background:'beige',padding:'20px'});
  var scroll = app.createScrollPanel().setPixelSize(450,300);
  var site = SitesApp.getSiteByUrl('https://sites.google.com/site/appsscriptexperiments/')
  var pages = site.getAllDescendants()
  var grid = app.createGrid(pages.length,2).setWidth(400)
    for(n=0;n<pages.length;++n){
    grid.setText(n, 0, pages[n].getName()).setWidget(n, 1, app.createAnchor('open', pages[n].getUrl()))
    }
    app.add(mainPanel.add(scroll.add(grid)))
    return app
}

I suppose you know ho to use it in your sitepage but just for info for anyone else : you have to go to manage site > script apps > create a new script > save a version > deploy with appropriate authorizations and finally return to your page and insert it as a gadget (better with a border and a size of 450x300, personal pov ^^) . You can also use it as a standalone webapp using its deploy url.

这篇关于您如何通过Google Apps脚本添加指向Google网站的链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 03:14