First, the disclaimer, I am not a developer. I am an Interaction Designer with average web skills and am trying to build an intranet within the confines of very limited Google Sites web building tools.
What I'm trying to accomplish:
I'm using a Google Site that has left-hand navigation for the main pages. Those main pages all link to product pages, and each product page has 7 sub pages (sometime less, never more).
I would like those sub-pages to appear in a horizontal row of tabs at the top.
The problem:
Google Site builder tools are very limited. I can have it present an automatic sub-page listing, but the only option it provides is to have the list of links appear in a vertical list.
From looking through the Google Site Help forums, this is by design, because Google seems to think that they know better than anyone. The response is that a sub-page list should only ever be vertical so that it has room to grow.
Fair enough, but we have standardized the structure for our product pages, and since we already have a vertical navigation bar for the main web content, it's also bad design practice to have a second level of vertical menus, so it is our choice to have the sub-pages appear as a horizontal navigation bar. But, Google Site builder tools do not provide any way of doing this.
I have been searching for a long time looking for a solution. I have investigated AwesomeTables, which are, yes, Awesome, but I don't want to hard-code my sub-page URLs in a spreadsheet just so I can get the web UI to look and behave the way I want.
I'm not one to give up, but I'm reaching the limits of my current abilities, not to mention my patience. This should be a simple task, and I have colleagues waiting for me to publish our intranet content so that we can get back to the business of being productive.
So, finally, to my question:
Can I use a Google Apps Script to create a horizontal row of tabs that are context-specific to the current top-level page and which will automatically generate links to the relevant sub-pages?
Is this what Fetch URL can do?
I have implemented a few pre-baked Apps Scripts already, so I understand the basic concepts, but I'm not able to create my own at this point.
I have been able to use the Custom HTML widget in the Google Site builder tools to create CSS decorated tabs, but I need to manually add the URL for every sub-page, and this will not scale with the size of my organization and the amount of content that multiple-authors need to contribute to.
Google Sites already has an automatic vertical sub-page listing widget.
I need that widget to display as horizontal tabs.
My guess is that can be accomplished with about 7 lines of code in a Google Apps Script.
Can anyone please provide some guidance on what those lines of code should look like? :-)
Update: I found this answer which I'm trying to modify as follows:
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://<siteURL>/');
var thisPage = SitesApp.getActivePage();
var pages = thisPage.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 thought that by adding a new var thisPage and having it call getActivePages that I could then feed that variable through 'pages' so that getAllDecendants is being filtered by 'thisPage' ...
However, it draws the beige background as defined in the 'grid' styling, but i'm not getting my list of URLs.
My first hurdle is simply to get the list of sub-pages based on the current page. I'm not looking for the code to be written for me, but I do appreciate any general help of how to create a hierarchy of variables so that my output of getAllDecendants is in the context of my thisPage variable.
I'll worry about decoration in a follow-up question, as this grid presentation is not what I want, but I'll build this up one item at a time, since I agree the initial question posed is a bit broad.
Many thanks in advance.
Jeremy