Upland OL User community

Change document title on general master page selectively [SOLVED]


I have an interesting case that I am unsure if it is at all possible. I have a generic master page that is used for a lot of our documents. On this master page template I have a placeholder that is used for the title of the document.

I have also created a general script that holds all the configuration information so I can keep a lot of the scripts the same for all our templates, which saves development time. One of the items in this script is a list of print contexts and the title that should belong to that print context. So, something like this:

title: {
	"PC_PrintContext1": "Document title 1",
	"PC_PrintContext2": "Document title 2"

merge.section.name holds the current print context so based on this I can look up the correct document title. Unfortunately this does not work since I use a general Master Page and running a script to replace a placeholder will update all placeholders on all pages.
Is there a way to still be able to do what I want to do without using a different master page for each print context and then use a unique place holder for each?

It seems this already works if I just target the section that should hold the title and then set the title conditionally:

if (gDocument.title[merge.section.name.toUpperCase()]) {
	title = gDocument.title[merge.section.name.toUpperCase()];
} else title = gDocument.name;


gDocument is the section that holds my JSON configuration and if the title cannot be found the default will be taken.