I have a template which consists of a nest of pages, sub-pages and sub-sub-pages. About 10 pages in the template in all, but it could grow. Every time I instantiate this template (always into the same doc), I get another 10 pages in my doc with the same page titles as last time. Since the new set of pages relates to something … errr … new, I amend all the page titles to include a character string which tells me what they’re about (e.g. VM023), which makes them unique again. It’s nice not to have 23 pages in the same doc which are all called “Windows Settings”! So now I’ve got one nest where all the page titles contain VM001, one nest with VM002, … and one nest with VM003.
The manual effort involved in all these repetitive changes to page titles irks me. Isn’t this what computers are for?
I want to be able to type the unique character string in somewhere, once, e.g. on the “top” page of the nest, and have formulae in each page title “calculate” a unique title for each page, based on the value I typed in (once).
Ironically, it seems that the title is just about the only place on a Coda page where typing “/” is possible, but does nothing. But it seems like the way Coda ought to “think”.
(Better still would be the ability to paramaterise the process of instantiating the template, along the lines of passing parameters into an object constructor. But now, I really am fantasising … )
Can anyone think of a way of doing this?
(I know I could probably get something similar with a canvas column in a table, but then I have to jump through hoops to express the nesting of the page hierarchy. )
The easier one would probably be to use the Doc Explorer Pack and once setup, add the Doc Pages sync table.
Once the table has synced all the pages in your doc, included the duplicated ones you want to rename, you can add a text field to store/formulaically determine the new name for the pages you want to rename and then setup an Update Page button available in the pack .
Once you click on the button, it will tell Coda API to update the name of the page according to the chosen/calculated name .
or … for a semi-working idea, as this would still require you to intervene, you could use DuplicatePage() and a one row helper table such as the one you see in the sample below ([Duplicate Pages]) where each blue button is setup to duplicate a specific page from the “template” and name it according to the “name” field next to it …
The purple button is there to push each individual blue button and update the value in the field [Dupl. Count] (as this used to name each duplicated pages).
Now, the thing is that I couldn’t find a way to name each individual duplicated page while still keeping the structure of the template … (as pages tends to be quite inflexible, I couldn’t simply reference a previously duplicated page as a parent for a page).
And this is why each page is created from the farthest position in the structure to the closest one under the page named Duplicated page… and this is where one would need to manually recreate the initial structure of the template …
It would probably be easier if we had a thisPage object (similar to thisDocument) we could reference in some way … or if DuplicatePage() would just accept “classical” page references (the @NameOfThePage one) instead of exclusively the one that can be used to be set as Value for new rows in a canvas column.
This was the only thing that prevented me to duplicate the pages while keeping the original structure …
I still just thought it might be worth mentioning it …
I’m new to Coda, so I have to be careful not to jump to conclusions.
My impression so far is that the design philosophy when it comes to user-defined activity is generally spreadsheet-ish. In other words, an object can “contain” a formula which can alter that object, and nothing else can alter that object. There is no general assignment operator which allows one thing to set the value of another.
I’ve noticed some exceptions, which are not spreadsheet-ish. These seem to be implemented as “alter thyself” methods which formulae elsewhere can call in conjunction with a reference to the target object. But the range of types of target object which can be referenced (and hence subject to external alteration) in this way is limited.
Coda is supposed to be an even-handed mix of the best of doc and the best of database. But my impression is that this external referencing is heavily table-centric, so the automation on the doc side of things is not as rich.
I’m coming at this from OneNote, which provides no user-definable automation at all. So I’m in the “any love is good love” camp when it comes to what Coda can do. Nonethless, I’ve always worked bottom-up (I think it’s called “Need-Driven Development”), where I put stuff in ad hoc, and then add structure and levels of abstraction as and when they look like paying off. The rather database-centric way of doing automation that Coda has feels as though it’s pushing in the other direction - you can suddenly do a whole lot more once you have a sufficiently high-octane problem to make it worth working within the relational paradigm. Meanwhile there are things it “should” be possible to do with much lower levels of structure and abstraction - particularly in the doc domain.
A simple grid control is another example. You can have a relational table, or you can have a text divided into columns (where there is no concept of a row). But no grid.
I noticed that there is a “Trial” button on the pack - free for 14 days, so I gave that a go. I’ve got through the basic set-up, to the point where I can update a single page Name with a literal string value.
Here’s my write-up of the hurdle I am now facing.
We have a nest of newly-created pages. The object is to replace the text “[XXX]” wherever it occurs in each of the page titles, with a text value.
There is a control “Tedt New VM ID” on the canvas which allows the user to enter a number. This is the number on which the replacement text value will be based.
Tedt New VM ID =1 ; replacement text =”001” ; This is equivalent to
LeftPad(ToText([Tedt New VM ID]),3,“0”)
Then we need a string substitution, so that
“VM[XXX]” → “VM001” ; “VM[XXX] Windows Settings” → “VM001 Windows Settings” etc.
There is an instance of the Doc Explorer “Update Page” button on the canvas.
At present, I am only trying to get it to update the title of one page - in this case the one initially titled “VM[XXX]”.
The ID of that page (from the Doc Explorer DocPages Table, after adding that column) is entered in the PAGE ID box
I want to alter the page NAME, so I add that box:
I need to form a formula to put in this box. The formula needs to retrieve the current value of the page Name, perform a string substitution on it, then assign it back to the page Name*. This is straightforward, except that I can’t see how to retrieve the current value of the page name. The formula needs to be like this, except that I can’t find what to put where PageName occurs:
substitute(PageName,“[XXX]”,LeftPad(ToText([Tedt New VM ID]),3,“0”))
This needs to be a reference to the Name attribute of the page referenced by canvas-Y1GA95W1_V
Can I form such a reference in this formula box, and if so, how?
If this can be done, I then want to extend this technique so that I am referring to the entire list of pages whose names currently contain “[XXX]”, performing the substitution on each of them, and assigning the correct modified string value to each. In other words, change them all with one button push.
A previous version of this formula succesfully assigned a constant string value “VM001” to the page Name. So I know that the assignment part of it works.