More in this section

Forums / Developing with Sitefinity / Page title automatically generated from navigational structure

Page title automatically generated from navigational structure

5 posts, 0 answered
  1. Pat
    Pat avatar
    20 posts
    Registered:
    18 Feb 2003
    21 Jul 2008
    Link to this post
    Hi there,
    i wonder if it is possible the page titles to be automatically created from the navigational structure. Something like "WebSite Title | Level1 | Level2 | Page name" as in the breabcrumb view.

    Thank you.

    Patrick
  2. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    22 Jul 2008
    Link to this post
    Hi Patrick Brill,

    It is possible.
    We have attached the code that will generate the title of every page dynamically. You should simply put it in your Project's App_Code directory and declare it in CmsEntryPoint.aspx which is located in your project folder:

    <%@ Page Inherits="SmartTitleInternalPage"
            
    MasterPageFile="~/Sitefinity/Dummy.master" %> 

    Note that you don't need to change anything in your pages, the code will change the titles for the old as well as for all newly-created pages.

    Please examine the code we sent. You could change the separator symbol as well as the string that the path starts with. You need to change only the values of PathSeparator and PathStartsWith variables.

    We hope you find this example helpful.


    All the best,
    Georgi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. Pat
    Pat avatar
    20 posts
    Registered:
    18 Feb 2003
    22 Jul 2008
    Link to this post
    Hello Georgi,
    Thank you very much. It works like a charme :-)
  4. Pat
    Pat avatar
    20 posts
    Registered:
    18 Feb 2003
    24 Jul 2008
    Link to this post
    Hello Georgi,
    it seems there is a problem with your code when i am indexing the pages. The index found x pages and x words what is obviously wrong. In an other thread I found that it happens if the indexer has a problem to index the pages at all. http://www.sitefinity.com/support/forums/support-forum-thread/b1043S-bkadee.aspx.
    Here is what i found in the sitefinity.log:

    - L0 -------------------------------------------------------------------------------

    Exception Type: Telerik.Framework.Search.IndexExcepton

    Message: An error has occurred while indexing the following document: "~/home/level2_2.aspx". Please see inner exception for more details.

    Source:

    Stack Trace:

    ------------------------------------------------------------------------------------

    - L1 -------------------------------------------------------------------------------

    Exception Type: System.Web.HttpException

    Message: Fehler beim Ausfhren der untergeordneten Anforderung fr /basfintranet2008/sitefinity/cmsentrypoint.aspx.

    Source: System.Web

    Stack Trace:

    bei System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride)

    bei System.Web.HttpServerUtility.Execute(String path, TextWriter writer, Boolean preserveForm)

    bei Telerik.Cms.Search.PageIndexerInfo.GetInternalPageData()

    ------------------------------------------------------------------------------------

    - L2 -------------------------------------------------------------------------------

    Exception Type: System.Web.HttpUnhandledException

    Message: Eine Ausnahme vom Typ System.Web.HttpUnhandledException wurde ausgelst.

    Source: System.Web

    Stack Trace:

    bei System.Web.UI.Page.HandleError(Exception e)

    bei System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

    bei System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

    bei System.Web.UI.Page.ProcessRequest()

    bei System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)

    bei System.Web.UI.Page.ProcessRequest(HttpContext context)

    bei ASP.sitefinity_cmsentrypoint_aspx.ProcessRequest(HttpContext context)

    bei System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride)

    ------------------------------------------------------------------------------------

    - L3 -------------------------------------------------------------------------------

    Exception Type: System.NullReferenceException

    Message: Object reference not set to an instance of an object.

    Source: App_Code.95hzho-8

    Stack Trace:

    bei SmartTitleInternalPage.GetFullPath(SiteMapNode node) in D:\WH4.Vorgang\Visual Studio Projekte\BASF\BASF Intranet 2008\BASF Intranet Sitefinity\App_Code\SmartTitleInternalPage.vb:Zeile 27.

    bei SmartTitleInternalPage.OnPreInit(EventArgs e) in D:\WH4.Vorgang\Visual Studio Projekte\BASF\BASF Intranet 2008\BASF Intranet Sitefinity\App_Code\SmartTitleInternalPage.vb:Zeile 19.

    bei System.Web.UI.Page.PerformPreInit()

    bei System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

    ------------------------------------------------------------------------------------

    I converted your code to VB:

    Imports System

    Imports System.Data

    Imports System.Configuration

    Imports System.Web

    Imports System.Web.Security

    Imports System.Web.UI

    Imports System.Web.UI.HtmlControls

    Imports System.Web.UI.WebControls

    Imports System.Web.UI.WebControls.WebParts

    Imports Telerik.Cms.Web

    ''' <summary>

    ''' Summary description for SmartTitleInternalPage

    ''' </summary>

    Public Class SmartTitleInternalPage

    Inherits InternalPage

    Protected Overloads Overrides Sub OnPreInit(ByVal e As EventArgs)

    MyBase.OnPreInit(e)

    Me.Title = GetFullPath(SiteMap.CurrentNode)

    End Sub

    Private Function GetFullPath(ByVal node As SiteMapNode) As String

    Dim PathSeparator As String = " | "

    ' How your path will start? With your project name? You could change

    ' it to anything else, for example PathStartsWith = "My Project > ";

    'Dim PathStartWith As String = UrlHelper.GetProjectName() + " | "

    Dim PathStartWith As String = "BASF EM Intranet | "

    If node.ParentNode Is Nothing Then

    Return PathStartWith

    End If

    If (Not node.ParentNode Is Nothing) AndAlso (Not node.ParentNode.ParentNode Is Nothing) Then

    Return [String].Concat(GetFullPath(node.ParentNode), PathSeparator, node.Title)

    Else

    Return [String].Concat(GetFullPath(node.ParentNode), node.Title)

    End If

    End Function

    End Class


  5. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    24 Jul 2008
    Link to this post
    Hi Patrick Brill,

    We have revised the code that we sent you earlier. Here's a slight modification - it should work now. Please note that your "breadcrumb" title will not be indexed.

    Greetings,
    Georgi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Register for webinar
5 posts, 0 answered