More in this section

Forums / Developing with Sitefinity / Display Tagname in NewsView

Display Tagname in NewsView

3 posts, 0 answered
  1. Mike
    Mike avatar
    22 posts
    Registered:
    05 Mar 2008
    19 Jun 2008
    Link to this post
    I have a page with a TagsList and a NewsView. When I click a tag in the list, the newsview is "filtered" by the selected tag via a querystringid field called NewsTagID.

    What i need to be able to do is display the actual tag name above the newsview, like a header.

    I tried doing this through code using the telerik api but i got a method not implemented error when trying to use the GetTag() method of the StaticNewsProvider, so i am guessing that is not the way to go.

    I can display the tags inside of the newsview but that displays All tags for each item. I just want to show the currently filtered tag name.


    Any help is appreciated
    Mike
  2. Mike
    Mike avatar
    22 posts
    Registered:
    05 Mar 2008
    19 Jun 2008
    Link to this post
    after mucking around with the API documentation and quite a bit of trial and error i worked up a solution.

    in the control template for my newsview control (which is actually holding job vacancies) i added the following

        Protected Sub repeater_PreRender(ByVal sender As Object, ByVal e As System.EventArgs)  
            Dim instance As New ContentManager  
            If Not Request.QueryString("NewsTagID") Is Nothing Then  
                Dim tagId As Guid = New Guid(Request.QueryString("NewsTagID"))             
                Dim tagname As String = instance.Providers("Vacancies").GetTag(tagId).TagName  
                litSelectedTag.Text += tagname  
            Else  
                litSelectedTag.Visible = False 
            End If  
              
        End Sub 
     
    and added a literal control to hold the tagname

    <asp:Literal ID="litSelectedTag" runat="server" Text="Currently Viewing: "></asp:Literal> 
     

    this does work well for my scenario, maybe it will be useful to someone else?

    for those that want/need it in c#

    protected void repeater_PreRender(object sender, System.EventArgs e)  
    {  
        ContentManager instance = new ContentManager();  
        if (!Request.QueryString("NewsTagID") == null)  
        {  
            Guid tagId = new Guid(Request.QueryString("NewsTagID"));  
            string tagname = instance.Providers("Vacancies").GetTag(tagId).TagName;  
            litSelectedTag.Text += tagname;  
        }  
        else  
        {  
            litSelectedTag.Visible = false;  
        }  
     


    modify it as you need.


    Mike
  3. Sonya
    Sonya avatar
    231 posts
    Registered:
    24 Sep 2012
    20 Jun 2008
    Link to this post
    Hi Mike,

    Thank you for providing the solution so that other people from the Sitefinity community could make use of it as well. Your Telerik account has been updated.

    Best wishes,
    Sonya
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Register for webinar
3 posts, 0 answered