Creating Title String in sitefinity

242 Views Asked by At

I am trying to create a unique title in sitefinity, the current title is something like this: "Chicken Sandwich". This is the code that is creating the title:

Page.Title  = (this._Product.PageTitle != "" ) ? this._Product.PageTitle : this._Product.Name;

I want to title to be something like this "Nutritional Information for Chicken Sandwich".

1

There are 1 best solutions below

1
jbokkers On

In Sitefinity 4/5 you kind of have 2 different titles. The first one is the 'name' of the page, the second is the Title for search engines. The name is seen throughout the backend of Sitefinity and is used in the navigation widgets. See screenshot here

You can retrieve both by the following statements:

string shorttitle = new PageManager().GetPageNode(new Guid(SiteMapBase.GetCurrentProvider().CurrentNode.Key)).Title;

and

string longtitle = new PageManager().GetPageNode(new Guid(SiteMapBase.GetCurrentProvider().CurrentNode.Key)).Page.HtmlTitle;

Hope it helps!

Jochem