Пример #1
0
        protected void rptRow_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.IsItem())
            {
                DefaultArticlePageItem dataItem = (DefaultArticlePageItem)e.Item.DataItem;

                if (dataItem.InnerItem.InheritsTemplate(DefaultArticlePageItem.TemplateId))
                {
                    DefaultArticlePageItem article = (DefaultArticlePageItem)dataItem;

                    System.Web.UI.WebControls.Image imgThumbnail = e.FindControlAs <System.Web.UI.WebControls.Image>("imgThumbnail");
                    HyperLink hypArticleLink = e.FindControlAs <HyperLink>("hypArticleLink");
                    HyperLink hypThumbnail   = e.FindControlAs <HyperLink>("hypThumbnail");
                    ArticleRecommendationIcons articleRecommendationIcons = e.FindControlAs <ArticleRecommendationIcons>("articleRecommendationIcons");

                    if (imgThumbnail != null)
                    {
                        imgThumbnail.ImageUrl = article.GetArticleThumbnailUrl(230, 129);
                    }

                    if (hypArticleLink != null)
                    {
                        hypArticleLink.NavigateUrl = hypThumbnail.NavigateUrl = article.GetUrl();
                        hypArticleLink.Text        = article.ContentPage.PageTitle;
                    }

                    if (IsUserLoggedIn)
                    {
                        articleRecommendationIcons.HasMatchingParentInterest = article.HasMatchingParentInterest(CurrentMember);
                        articleRecommendationIcons.MatchingChildrenIds       = article.GetMatchingChildrenIds(CurrentMember);
                    }
                }
            }
        }
        protected void rptAuthorArticles_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.IsItem())
            {
                DefaultArticlePageItem article = (DefaultArticlePageItem)e.Item.DataItem;

                if (article != null)
                {
                    HyperLink hypImageLink        = e.FindControlAs <HyperLink>("hypImageLink");
                    HyperLink hypAuthor           = e.FindControlAs <HyperLink>("hypAuthor");
                    HyperLink hypReadMore         = e.FindControlAs <HyperLink>("hypReadMore");
                    HyperLink hypArticleTitleLink = e.FindControlAs <HyperLink>("hypArticleTitleLink");
                    Literal   litCommentCount     = e.FindControlAs <Literal>("litCommentCount");
                    Literal   litArticleTitle     = e.FindControlAs <Literal>("litArticleTitle");
                    Literal   litDatePosted       = e.FindControlAs <Literal>("litDatePosted");
                    Literal   litAbstract         = e.FindControlAs <Literal>("litAbstract");
                    ArticleRecommendationIcons articleRecommendationIcons = e.FindControlAs <ArticleRecommendationIcons>("articleRecommendationIcons");

                    if (article.AuthorName.Item != null)
                    {
                        hypAuthor.Text        = article.AuthorName.Item.DisplayName;
                        hypAuthor.NavigateUrl = Sitecore.Context.Item.GetUrl();

                        hypImageLink.NavigateUrl = hypReadMore.NavigateUrl = hypArticleTitleLink.NavigateUrl = article.GetUrl();
                        hypImageLink.ImageUrl    = article.GetArticleThumbnailUrl(230, 129);

                        litArticleTitle.Text = article.DisplayName;
                        litDatePosted.Text   = article.InnerItem.Statistics.Created.ToString("MMM dd, yyyy");
                        litAbstract.Text     = UnderstoodDotOrg.Common.Helpers.TextHelper.TruncateText(
                            Sitecore.StringUtil.RemoveTags(HttpUtility.HtmlDecode(article.ContentPage.BodyContent.Raw)), 150);

                        bool hasMoreResults;
                        int  totalComments;

                        List <Comment> dataSource = TelligentService.ReadComments(
                            article.BlogId.ToString(), article.BlogPostId.ToString(), 1, Constants.ARTICLE_COMMENTS_PER_PAGE, "CreatedUtcDate", true, out totalComments, out hasMoreResults);

                        litCommentCount.Text = totalComments.ToString();

                        if (IsUserLoggedIn)
                        {
                            articleRecommendationIcons.HasMatchingParentInterest = article.HasMatchingParentInterest(CurrentMember);
                            articleRecommendationIcons.MatchingChildrenIds       = article.GetMatchingChildrenIds(CurrentMember);
                        }
                    }
                    else
                    {
                        e.Item.Visible = false;
                    }
                }
            }
        }