コード例 #1
0
        protected List <BlogPost> InitContent()
        {
            BlogPageItem    blogPage   = Sitecore.Context.Item;
            string          blogId     = blogPage.BlogId;
            List <BlogPost> dataSource = TelligentService.ListBlogPosts(blogId, "100");

            foreach (var item in dataSource)
            {
                BlogsPostPageItem blogPost;
                if (item.Title.Contains("{"))
                {
                    string[] s = item.Title.Split('{');
                    item.Title = s[0];
                    blogPost   = Sitecore.Context.Database.GetItem("{" + s[1]);
                }
                else
                {
                    blogPost = Sitecore.Context.Database.GetItem("/Sitecore/Content/Home/Community and Events/Blogs/" + item.BlogName + "/" + item.Title);
                }
                BlogsAuthorPageItem author = Sitecore.Context.Database.GetItem(blogPost.Author.Raw);
                item.Author    = author.Name;
                item.Body      = TelligentService.FormatString100(Sitecore.StringUtil.RemoveTags(blogPost.Body.Raw));
                item.AuthorUrl = LinkManager.GetItemUrl(author);
            }
            return(dataSource);
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            BlogsPostPageItem blogCig = new BlogsPostPageItem(Sitecore.Context.Item);

            litFormattedDate.Text = blogCig.Date.DateTime.ToString("M/dd/yyyy");
            BlogsAuthorPageItem author = Sitecore.Context.Database.GetItem(blogCig.Author.Raw);

            linkAuthor.HRef   = linkAuthor2.HRef = linkAuthor3.HRef = LinkManager.GetItemUrl(author);
            litAuthorBio.Text = CommunityHelper.FormatString100(author.Biography.Text) + "...";
            litAuthor.Text    = litAuthor2.Text = author.Name;
        }
コード例 #3
0
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            Panel panResultText = (Panel)FindControl("panResultText");

            panResultText.Visible = true;

            Literal litResultCount = (Literal)FindControl("litResultCount");
            Literal litSearchTerm  = (Literal)FindControl("litSearchTerm");

            Repeater rptRecentBlogInfo = (Repeater)FindControl("rptRecentBlogInfo");
            string   query             = TextHelper.RemoveHTML(txtSearch.Text);
            var      dataSource        = TelligentService.CommunitySearch(query, Constants.TelligentSearchParams.Blog, Constants.BlogNames[Sitecore.Context.Item["BlogId"]]);

            litSearchTerm.Text = query;

            if (dataSource.Any())
            {
                foreach (var item in dataSource)
                {
                    string[]          s        = item.Title.Split('{');
                    BlogsPostPageItem blogPost = Sitecore.Context.Database.GetItem(String.Format("{0}{1}", "{", s[1]));

                    if (blogPost != null)
                    {
                        item.Title = s[0].Trim();

                        if (!item.Title.ToLower().Contains("comment on"))
                        {
                            item.Body = Sitecore.StringUtil.RemoveTags(TelligentService.FormatString100(blogPost.Body));
                        }

                        BlogsAuthorPageItem author = Sitecore.Context.Database.GetItem(blogPost.Author.Raw);
                        if (author != null)
                        {
                            item.Author = author.Name;
                        }
                        else
                        {
                            item.Author = null;
                        }

                        var telligentDetails = TelligentService.ReadBlogBody(blogPost.BlogId, blogPost.BlogPostId);
                        item.CommentCount = telligentDetails.CommentCount;
                    }
                }
            }

            litResultCount.Text = dataSource.Count.ToString();

            rptRecentBlogInfo.DataSource = dataSource;
            rptRecentBlogInfo.DataBind();
        }
コード例 #4
0
        void lvAuthors_ItemDataBound(object sender, ListViewItemEventArgs e)
        {
            if (e.Item.ItemType == ListViewItemType.DataItem)
            {
                BlogsAuthorPageItem author = (BlogsAuthorPageItem)e.Item.DataItem;

                FieldRenderer frAuthorName = (FieldRenderer)e.Item.FindControl("frAuthorName");

                frAuthorName.Item = author;

                HyperLink hypAuthorImage = (HyperLink)e.Item.FindControl("hypAuthorImage");
                HyperLink hypAuthorName  = (HyperLink)e.Item.FindControl("hypAuthorName");

                hypAuthorImage.NavigateUrl = hypAuthorName.NavigateUrl = author.GetUrl();
            }
        }