Custom browser tab names

Forum
Last Post
Threads / Messages

Dinocanid

Member
Member
Joined
Aug 30, 2016
Messages
520
Points
18
Age
23
Location
Maryland, USA
Mysidian Dollar
43,334
It was bothering me for the longest time how the tab name in your browser was always the name of your site, no matter what page you're on. Imagine members opening multiple tabs for different pages on your site and they can't tell which is which! I went ahead and fixed that.

-Step 1-
Go to public_html/templates/(Whatever theme you're using)/header.tpl. See the lines that look like this?:
Code:
<title>{$browser_title}</title>
Delete them. In case you have two of these lines, delete them both. If you feel uncomfortable about deleting them (maybe you want it for later?), just comment them out like this:
Code:
<! --<title>{$browser_title}</title> -->

-Step 2-
Now you can rename the tabs! For example, let's rename the tab of the inventory page. Go to inventoryview.php, find these lines:
PHP:
public function index(){
	    $mysidia = Registry::get("mysidia");
		$document = $this->document;
		$document->setTitle($mysidia->lang->inventory);

And change it to this:
PHP:
public function index(){
	    $mysidia = Registry::get("mysidia");
		$document = $this->document;
$document->add(new Comment("<title>Inventory</title>"));
		$document->setTitle($mysidia->lang->inventory);

-End-
You're done! The downside is that you'll have to do this for all of your pages, or else the tab name will just be the full URL. This works for pages made in the adminCP too! Just go to edit your custom page and add this before the rest of your content:
Code:
<title>Tab Title</title>

-Why edit the code?-
I found that if you attempt to use the html title tags without editing the header.tpl, then they won't work because they're being overridden. It is also important to note that this doesn't conflict with:
$document->setTitle("Title");
Because that is for the title on the actual page itself, not the browser tab.
 
Last edited:

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,277
Messages
33,118
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Latest Posts

Top