Overriding Home Page title
Overriding Home Page title
Is there any way to override the title that is entered n Website-->Webpages-->Home Page so that it can be controlled directly via the .aspx or .aspx.cs file? Because we run two websites off of the same DB we need to use two different titles, but Gold stores the title in the DB.
Rick Morris
Brewhaus (America) Inc.
Hot Sauce Depot
Brewhaus (America) Inc.
Hot Sauce Depot
-
- Commodore (COMO)
- Posts: 436
- Joined: Tue May 07, 2013 1:59 pm
Re: Overriding Home Page title
It appears to be set towards the bottom of Webpages.aspx.cs (in the root website folder).
Perhaps in one of your stores you could put an if statement around this that checks to see if it is the home page (_webpage.Name == "Home Page"), and if so, set Page.Title to a specific string instead of using the value from the database?
Code: Select all
Page.Title = string.IsNullOrEmpty(_webpage.Title) ? _webpage.Name : _webpage.Title;
Jay
Re: Overriding Home Page title
Thank you for the information. I can simply hard code the page title for one of the websites by changing the line to Page.Title = "desired title";, but does this file control any other webpages? I looked around a little bit and it does not appear to, but I want to make sure before going this direction.
Rick Morris
Brewhaus (America) Inc.
Hot Sauce Depot
Brewhaus (America) Inc.
Hot Sauce Depot
-
- Commodore (COMO)
- Posts: 436
- Joined: Tue May 07, 2013 1:59 pm
Re: Overriding Home Page title
Well you can try to have multiple titles seperated by some special character and then before setting the title you can split it into multiples. Finally you can pick one of them depending upon your domain. For example edit the Website/Webpage.aspx.cs file and locate following code
and replace it with
Now update the "firstdomain.xyz" with domain name where you would like to have first part of title seperated by pipe sign. Finally in admin panel if you update the home page title somthing like "First Home Page | Second Home Page" it should show the title First Home Page if you open home for frist domain.
Code: Select all
Page.Title = string.IsNullOrEmpty(_webpage.Title) ? _webpage.Name : _webpage.Title;
Code: Select all
if (!string.IsNullOrEmpty(_webpage.Title))
{
if (_webpage.Title.Contains("|"))
{
string[] titles = _webpage.Title.Split('|');
if (Request.Url.AbsolutePath.Contains("firstdomain.xyz"))
Page.Title = titles[0];
else
Page.Title = titles[1];
}
else
{
Page.Title = _webpage.Title;
}
}
else
{
Page.Title = _webpage.Name;
}
Re: Overriding Home Page title
Thank you, Mazhar. I was going to just hard-code the title for the second website into the webpage.aspx.cs file, but your option definitely offers a more flexible solution! 

Rick Morris
Brewhaus (America) Inc.
Hot Sauce Depot
Brewhaus (America) Inc.
Hot Sauce Depot