Beispiel #1
0
        protected void rptTopicListItems_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.IsItem())
            {
                DefaultArticlePageItem item = (DefaultArticlePageItem)e.Item.DataItem;

                HyperLink hlTopicTitle = e.FindControlAs <HyperLink>("hlTopicTitle");
                hlTopicTitle.NavigateUrl = item.GetUrl();
                hlTopicTitle.Text        = item.ContentPage.PageTitle.Rendered;

                PlaceHolder phThumbnail = e.FindControlAs <PlaceHolder>("phThumbnail");

                var icons = e.FindControlAs <UnderstoodDotOrg.Web.Presentation.Sublayouts.Recommendation.ArticleRecommendationIcons>("ArticleRecommendationIcons");
                if (icons != null)
                {
                    icons.MatchingChildrenIds       = item.GetMatchingChildrenIds(CurrentMember);
                    icons.HasMatchingParentInterest = item.HasMatchingParentInterest(CurrentMember);
                }

                // Handle first image
                if (e.Item.ItemIndex == 0)
                {
                    Image  imgThumbnail = e.FindControlAs <Image>("imgThumbnail");
                    string source       = item.GetArticleFeaturedThumbnailUrl(190, 107);
                    imgThumbnail.ImageUrl = source;
                    phThumbnail.Visible   = !String.IsNullOrEmpty(source);
                }
                else
                {
                    phThumbnail.Visible = false;
                }
            }
        }
Beispiel #2
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;
                    }
                }
            }
        }
Beispiel #4
0
        private void BindContent()
        {
            if (DataSource != null)
            {
                DefaultArticlePageItem article = DataSource;

                frPageTitle.Item        = article;
                imgThumbnail.ImageUrl   = article.GetArticleThumbnailUrl(190, 107);
                hlThumbnail.NavigateUrl = hlTitle.NavigateUrl = article.GetUrl();

                articleRecommendationIcons.HasMatchingParentInterest = article.HasMatchingParentInterest(CurrentMember);
                articleRecommendationIcons.MatchingChildrenIds       = article.GetMatchingChildrenIds(CurrentMember);
            }
        }