Sitefinity Custom Page Title
sitefinity | .NET, CMS, Sitefinity | 2021-02-20
sitefinity | .NET, CMS, Sitefinity | 2021-02-20
– To modify the Page Title to "ABC Inc | (Page_Title)" on the fly
Add the title tag with id attribute:
<html>
<head runat="server">
<title id="page_title"></title>
</head>
<body runat="server">
<p>Lorem Ipsum</p>
</body>
</html>
Update page title at Page_Load override method:
protected void Page_Load(object sender, EventArgs e)
{
var man = PageManager.GetManager();
if (SiteMapBase.GetActualCurrentNode() != null)
{
try
{
var getCurrentPage = SiteMapBase.GetActualCurrentNode().Id;
if (getCurrentPage != Guid.Empty)
{
page_title.Text = page.Title != null ? string.Format("ABC Inc | {0}", page.Title.ToString()) : "ABC Inc | Apple Balloon Crazy";
}
}
catch (Exception ex)
{
Log.Write("Template ERROR. " + ex.Message + " " + ex.StackTrace);
page_title.Text = "ABC Inc | Apple Balloon Crazy";
}
}
}
@{
var page = (Page)HttpContext.Current.Handler;
((System.Web.UI.HtmlControls.HtmlTitle)page.Header.FindControl("page_title")).Text = <your_page_title> != null ? string.Format("ABC Inc | {0}", <your_page_title>) : string.Format("{0}", page.Title);
}