Overriding Home Page title

For general questions and discussions specific to the AbleCommerce GOLD ASP.Net shopping cart software.
Post Reply
Brewhaus
Vice Admiral (VADM)
Vice Admiral (VADM)
Posts: 878
Joined: Sat Jan 19, 2008 4:30 pm

Overriding Home Page title

Post by Brewhaus » Mon Sep 09, 2013 12:17 pm

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

jguengerich
Commodore (COMO)
Commodore (COMO)
Posts: 436
Joined: Tue May 07, 2013 1:59 pm

Re: Overriding Home Page title

Post by jguengerich » Wed Sep 11, 2013 12:09 pm

It appears to be set towards the bottom of Webpages.aspx.cs (in the root website folder).

Code: Select all

            Page.Title = string.IsNullOrEmpty(_webpage.Title) ? _webpage.Name : _webpage.Title;
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?
Jay

Brewhaus
Vice Admiral (VADM)
Vice Admiral (VADM)
Posts: 878
Joined: Sat Jan 19, 2008 4:30 pm

Re: Overriding Home Page title

Post by Brewhaus » Wed Sep 11, 2013 7:39 pm

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

jguengerich
Commodore (COMO)
Commodore (COMO)
Posts: 436
Joined: Tue May 07, 2013 1:59 pm

Re: Overriding Home Page title

Post by jguengerich » Thu Sep 12, 2013 6:39 am

I'm not sure if does or not, maybe someone from AC can answer.
Jay

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Overriding Home Page title

Post by mazhar » Mon Sep 16, 2013 10:18 am

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

Code: Select all

Page.Title = string.IsNullOrEmpty(_webpage.Title) ? _webpage.Name : _webpage.Title;
and replace it with

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;
            }
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.

Brewhaus
Vice Admiral (VADM)
Vice Admiral (VADM)
Posts: 878
Joined: Sat Jan 19, 2008 4:30 pm

Re: Overriding Home Page title

Post by Brewhaus » Mon Sep 16, 2013 10:28 am

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

Post Reply