Sorry, yes, I was referring to the page title as it appears in the browser (i.e. the <title>
tag -- although what I really want to modify is only the DocumentPageTitle, because I want the system to still honor my "Page title format" setting I have set for the site in Settings -> Content.)
What I was hoping for was maybe a macro I can use in the "Page title" field of the Metadata tab for the document. For example, something along the lines of:
{% CurrentDocument["MyDataSource"].Items.Count == 1 ? CurrentDocument["MyDataSource"].Items[0].DisplayName : "Not found" |(identity)GlobalAdministrator%}
But that only works because the profile loaded into MembershipContext.CurrentUserProfile
is hard-coded to look for a userid, username, or userguid supplied in the query string. It's very specific to showing user profiles.
So I certainly could write some custom code that works similarly to MembershipContext.CurrentUserProfile, but I was really hoping for a more generic solution that could be employed for any DataSource, because I anticipate this being something I'll need to do more in the future, and I didn't want to have to rely on writing custom code for each and every single situation like this.
Using the transformation to handle this just doesn't seem to be the correct solution. That seems totally out of the scope of what a transformation does or should do, and could lead to confusing behavior if someone working with it in the future doesn't just happen to know that it will change the page title (and they likely won't). If there's no out-of-the-box solution for this type of thing, I think I'll probably just create a custom web part that can change the page the title based on a DataSource -- that's much more explicit, and could still be used without writing custom code each time.