Page titles in perspective

Hi!
Is there a practical way to change the title of a page?
The release notes suggest using a script, but how is that done? How do I tell the script how to reach each page (like, how do I integrate [url]+[page.props.title])?

And on another note, how do I change/remove the suffix “- Perspective” from the page title? (in this example, I wrote “Ignition - Diagrama Unifilar”, but the suffix was automatically added)
image

I have changed this title using a text field with a bidirectional binding and on the browser just typing the new name, but I know this is NOT the best way to do so, specially when you have lots of different pages.

I did some further testing using the Text field and these are my results:

  • “Diagrama unifilar” had it’s name after I removed the text field (and saved the project).
  • From “Diagrama Uniflar” a template page (with it’s unique url [templatepage/:machinename]) was opened for machine A, in which I placed the same text field I had before on “diagrama unifilar”. Said text field read “Ignition base”, however when I changed it, the title was kept for Machine B page’s.
  • Once in Machine B, I changed the title again and it remained static back to Machine A AND back to “diagrama Unifilar”.

In the PageStartup script, you should set the page title based on the page path (Project > Session Events > Page Startup).

if page.props.path == '/tabularasa':
	page.props.title = 'Test'

Screen Shot 2021-02-17 at 1.18.01PM
There is not currently a way to remove the " - Perspective" at the end of the tab title.

Ok I have 0.16 but I don’t see the Page StartUp option on the Session Events window.

Am I doing something wrong? Should I click on something before opening the dialogue to get that option?

Whoops, sorry - that feature was introduced in 8.1.0. I thought it was older than that. You could get close to doing the same thing in the View startup script, but you can run into issues later on if you ever use the given view as more of a template because you’re making the assumption that the View is used as the primary view when it might not be.

Right-click the view node in the project editor, and select “Configure Events”. Select onStartup, and select a Script Action for use.
Use the following script:

self.page.props.title = "Test"
1 Like

Gotcha!

So if I have a breakpoint page (with 2 views), a script will be needed for each view, but it will create conflict, correct?

Also, how do we suggest a change on the documentation? This page says that feature is available from 8.0.16 when it’s from 8.1.0.

When the page loads, whichever view is used will set the title. When the breakpoint changes to use the other view, then this “new” view will have its own View startup event execute, and so it will overwrite whatever the other had already put in place. The same will happen if you move back to the other breakpoint.

I’ll reach out to the doc team, but I feel like we’ve already had this discussion about this very feature… Let me get back to you.

1 Like

Thanks a lot! I got it working.

Now, What I did was not only rely on the view startup event, but since my view is based on a template and the reference value is stored as a PARAM, I added a change value script that monitors said PARAM.

Now whenever I change between machines, the title displays the correct title (it didn’t change using only onStartUp because the page didn’t reload, it just altered the tag routes).

1 Like

The - Perspective is gone as of 8.1.6 as well as able to configure page title without the need for scripting :+1:

2 Likes

Huh! I missed the update, thanks for the heads up!

the problem with this script is whenever you refresh the URL, it grabs the project title name instead of the string passed in self.page.props.title.

Any suggestions on this?