This topic is locked
[SOLVED]

Change Page Title according to Selected Tab

1/6/2025 5:01:02 AM
PHPRunner General questions
K
Kevin Millican author

Hi everyone. I am stuck on a design issue and I wondered if anyone else has come across it and had a solution.

The main page of my website has a number of help topics.

I would like to alter the web $PageTitle according to which tab is selected. At the moment it just says "Information" for all of them.
I know that I can change this in the Labels section, and I have had some success using Labels::setPageTitleTempl($table, $page, $title, $language)

However, even with session variables, I don't appear to be able to record the desired tab in time to change it unless I press the tab twice.
It's all to do with the order of events.

Any suggestions would be appreciated.

C
cristi 1/6/2025

One easy way to do it - on list page javascript onload event:

var yetanothertitle= $("li[class=active]").find("a").text(); //get the text of the active tab

//or you can use innerHTML:
var yetanothertitle=$("li[class=active]").find("a")[0].innerHTML;

document.title=yetanothertitle; //set the page title

There may be additional information displayed - if you have a count for that tab, the active index, etc- you can filter that using javascript again.

K
Kevin Millican author 1/6/2025

Thanks cristi - that worked great - though the .text() syntax caused two of my tabs to have an additional character "1" in the page title.

The .innerHTML syntax worked perfectly, though I decided to modify the page titles slightly as the tabs were abbreviated.

Thanks again.