More in this section

Forums / Developing with Sitefinity / Blog lookup by URL

Blog lookup by URL

2 posts, 0 answered
  1. bnye
    bnye avatar
    332 posts
    Registered:
    22 Sep 2005
    20 Jun 2007
    Link to this post
    Sorry for the barrage of posts, but I was trying to implement a usercontrol that would set the page title based on the current blog post title. And the same for the news items. Can you point me to the correct class for performing this task based on the current URL.

    Sincerely,

    Ben
  2. Bob
    Bob avatar
    330 posts
    Registered:
    30 Dec 2016
    20 Jun 2007
    Link to this post
    Hi Ben,

    Good idea; this should be property of SingleNews/Post controls. Here is an example how you could do this:
    VB:
    ' Current HttpContext  
    Dim obj As Object = Context.Items("ArticleID")  
    If obj <> Nothing Then 
        'Important: The correct provider name should be specified  
        Dim manager As New ContentManager("News")  
        Dim article As IContent = manager.GetContent(DirectCast(obj, Guid))  
        Page.Title = DirectCast(article.GetMetaData("Title"), String)  
    End If 

    C#:
    // Current HttpContext  
    object obj = Context.Items["ArticleID"];  
    if (obj != null)  
    {  
        //Important: The correct provider name should be specified  
        ContentManager manager = new ContentManager("News");  
        IContent article = manager.GetContent((Guid)obj);  
        Page.Title = (string)article.GetMetaData("Title");  


    All the best,
    Bob
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
2 posts, 0 answered