More in this section

Forums / Developing with Sitefinity / Display post by reporter

Display post by reporter

7 posts, 1 answered
  1. Steven Lancaster
    Steven Lancaster avatar
    82 posts
    Registered:
    06 Nov 2009
    23 Jan 2010
    Link to this post
    I have a page that displays a reporter and his biography information. I also want to display the posts that are associated with that reporter. Is there some sample code that I can use to accomplish this?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    24 Jan 2010
    Link to this post
    Hi Steven Lancaster,

    The easiest way is using tags or categories. Otherwise you need to think about some identifier that will be used to make the relation between all other posts.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Steven Lancaster
    Steven Lancaster avatar
    82 posts
    Registered:
    06 Nov 2009
    26 Jan 2010
    Link to this post
    We have a reporter assigned to every post. I have uploaded a picture that shows the reporter field. Do you have any sample code that may do this or an example.

    Let me explain what I am doing I am creating a reporter with a biography and putting it under Modules - Generic Content then categorizing as a reporter. I want to have a page that pulls up the biography and list the posts for that reporter.

    Any help is greatly appreciated.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    26 Jan 2010
    Link to this post
    Hi Steven Lancaster,

    The ContentView controls has a property FilterExpression which you can use to filter all items by Category or by your metakey. Doesn't this helps in your case?

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Answered
  5. Steven Lancaster
    Steven Lancaster avatar
    82 posts
    Registered:
    06 Nov 2009
    26 Jan 2010
    Link to this post
    That worked perfectly!!!
  6. Steven Lancaster
    Steven Lancaster avatar
    82 posts
    Registered:
    06 Nov 2009
    26 Jan 2010
    Link to this post
    I have the following pages: The first is a .ascx file the second is the .ascx.cs file. It is showing up for some reporters but not all can you see a problem in my logic?

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="PostByReporter.ascx.cs" Inherits="Sitefinity_ControlTemplates_Blogs_PostByReporter" %> 
    <%@ Register Assembly="Telerik.Blogs" Namespace="Telerik.Blogs.WebControls" TagPrefix="sfWeb" %> 
    <%@ Register Assembly="Telerik.Cms.Engine" Namespace="Telerik.Cms.Engine.WebControls" TagPrefix="sfWeb" %> 
    <%@ Register Assembly="Telerik.Cms.Web.UI" Namespace="Telerik.Cms.Web.UI" TagPrefix="sfCtrl" %> 
    <%@ Register Assembly="Telerik.Cms.Web.UI" Namespace="Telerik.Cms.Web.UI" TagPrefix="sfWeb" %> 
    <sfWeb:CssFileLink ID="CssFileLink1" FileName="~/Sitefinity/ControlTemplates/Blogs/blogsLayout.css" Media="screen" runat="server" /> 
     
    <%@ Register TagPrefix="TN" TagName="ucPostAnonomously" Src="~/Sitefinity/ControlTemplates/Blogs/ucPostAnonomously.ascx" %> 
    <%@ Register TagPrefix="TN" TagName="ucSendFriend" Src="~/Sitefinity/ControlTemplates/Blogs/ucSendFriend.ascx" %> 
     
    <div style="clear:both;"></div> 
    <asp:Repeater ID="repeater" runat="server" OnItemDataBound="repeater_ItemDataBound">  
     <HeaderTemplate> 
            <ul class="sf_postListing">  
        </HeaderTemplate> 
        <ItemTemplate> 
            <li id="liPost" runat="server">  
                <h2 class="sf_postTitle">  
                    <asp:HyperLink ID="fullContent1" runat="server">  
                        <asp:Literal ID="Title" runat="server"></asp:Literal> 
                    </asp:HyperLink> 
                </h2>              
     
                <class="sf_postDate">  
                    <sfCtrl:DateTimeLiteral runat="server" ID="Publication_Date" DateFormatString="D"></sfCtrl:DateTimeLiteral> 
                </p> 
                <asp:Panel id="pnlPostContent" runat="server" CssClass="sf_postContent">  
                    <asp:Literal ID="content" runat="server"></asp:Literal> 
                </asp:Panel> 
                  
                <class="sf_postComments">  
     
                <%--<div class="bTags"><span>Tags:</span>   
                    <asp:Repeater ID="Repeater1" runat="server">   
                          <ItemTemplate>   
                                <asp:HyperLink ID="tagLink" runat="server" />   
                          </ItemTemplate>     
                      </asp:Repeater>     
                </div>--%> 
                <div class="allReports"></div> 
                 <div class="clearing"></div> 
                   
                    <div class="grid-btBlock">  
                    <div class="cPosts">  
                        
                    <%--<asp:HyperLink cssclass="post-a-comment" ID="CommentsLink" runat="server" NavigateUrl="{0}#comments">--%> 
                    <asp:HyperLink cssclass="post-a-comment" ID="CommentsLink" NavigateUrl='<%#string.Format("~/BlogComment/{0}.aspx#comments",DataBinder.Eval(Container.DataItem, "URL"))%>' runat="server">  
                    &nbsp;  
                    </asp:HyperLink> 
                    <%--<asp:HyperLink ID="fullContent3" runat="server" NavigateUrl="{0}#comments">--%> 
                    <asp:HyperLink cssclass="" ID="HyperLink1" NavigateUrl='<%#string.Format("~/BlogComment/{0}.aspx#comments",DataBinder.Eval(Container.DataItem, "URL"))%>' runat="server">  
                      <span class="count"><asp:Label ID="CommentsCount" runat="server"></asp:Label> Posts</span></asp:HyperLink> 
                          
                    </div> 
                  </div> 
                </p> 
                  
                <p></p>  
                  
            </li> 
              
        </ItemTemplate> 
        <FooterTemplate> 
            </ul> 
        </FooterTemplate> 
    </asp:Repeater> 
     
     
     
     
     
    using System;  
    using System.Data;  
    using System.Configuration;  
    using System.Web;  
    using System.Web.Security;  
    using System.Web.UI;  
    using System.Web.UI.HtmlControls;  
    using System.Web.UI.WebControls;  
    using System.Web.UI.WebControls.WebParts;  
    using Telerik.News.WebControls;  
    using Telerik.Cms.Web;  
    using Telerik.Cms.Engine;  
    using Telerik.Cms.Engine.ContentViewFiltering;  
    using System.Collections;  
    using Telerik.Blogs;  
    using DeepBlueCore;  
     
    public partial class Sitefinity_ControlTemplates_Blogs_PostByReporter : System.Web.UI.UserControl  
    {  
        protected void Page_Load(object sender, EventArgs e)  
        {  
     
        }  
     
        #region Events  
        protected void repeater_ItemDataBound(object sender,  RepeaterItemEventArgs e)  
        {  
            if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))  
            {  
                HtmlControl liPost = (HtmlControl)e.Item.FindControl("liPost");  
     
                IContent dataItem = (IContent)e.Item.DataItem;  
     
                if (Common.QueryString("rpt") == (string)dataItem.GetMetaData("Reporter"))  
                {  
                    liPost.Visible = true;  
                }  
                else  
                {  
                    liPost.Visible = false;  
                }              
            }  
        }  
     
        #endregion     
    }  
     
  7. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    26 Jan 2010
    Link to this post
    Hi Steven Lancaster,

    It seems that this code has something to do with the visibility

    if (Common.QueryString("rpt") == (string)dataItem.GetMetaData("Reporter")) 
     
         liPost.Visible = true
     
     else 
     
         liPost.Visible = false
     }


    Greetings,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Register for webinar
7 posts, 1 answered