1
votes

I need to show in every webpage, the following structure of title:

"title of the WebSite/Project" +","+ "title of the 1º site" +","+ "title of the 2º site" +","+ "title of the page"

For example, i have a webpage with the title "Last news webpage" and I am in a site with the following path: /news/international/new1.aspx. The site "news" has the title: "News", the site "international" has the title "International News" and the page has the title "New planet discovered". The result should be:

Last news webpage, news, international news, New Planet discovered

How can i do this using the ProjectProperty tag of Sharepoint?

If it can't be done, how can i do it with at least one level of site? ("Last news webpage, news, new planet discovered")

1

1 Answers

1
votes

You may want to investigate building your own server control that creates the appropriate title and add it to the site's masterpage.

here's a tutorial for creating a custom server control.

the code to get the custom server control to render the appropriate site information would be something like the following:

protected override void RenderContents(HtmlTextWriter writer)
{
  if (Context != null)
  {
      SPWeb l_web = SPContext.Current.Web;
      StringBuilder l_titleBuilder = new StringBuilder();
      l_titleBuilder.AppendFormat("{0}, ", l_web.Title);

      char[] l_delim = new char { '/' };
      foreach ( string l_pathComponent in 
                     l_web.ServerRelativeUrl.Split(l_delim) )
         l_titleBuilder.AppendFormat("{0}, ", l_pathComponent);

      l_titleBuilder.Remove(l_titleBuilder.Length - 2, 2);
      writer.Write(l_titleBuilder.ToString());
   }
}