コード例 #1
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;
        }
コード例 #2
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();
        }
コード例 #3
0
        private void Page_Load(object sender, EventArgs e)
        {
            string blogId = Request.QueryString["BlogId"];
            List <UnderstoodDotOrg.Domain.TelligentCommunity.BlogPost> dataSource = CommunityHelper.ListBlogPosts(blogId, "100");

            foreach (var item in dataSource)
            {
                BlogsPostPageItem blogPost = Sitecore.Context.Database.GetItem("/Sitecore/Content/Home/Community and Events/Blogs/" + item.BlogName + "/" + item.Title);
                item.Author    = blogPost.Author.Rendered;
                item.Body      = CommunityHelper.FormatString100(CommunityHelper.FormatRemoveHtml(blogPost.Body.Raw));
                item.AuthorUrl = "/Community and Events/Blogs/Author/" + item.Author;
            }
            rptBlogInfo.DataSource = dataSource;
            rptBlogInfo.DataBind();
        }
コード例 #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string blogId     = Settings.GetSetting(Constants.Settings.TelligentBlogIds);
            var    dataSource = TelligentService.ListBlogPosts(blogId, "3");

            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)
                {
                    var author = Sitecore.Context.Database.GetItem(blogPost.Author.Raw);
                    item.Author        = author.Name;
                    item.Title         = blogPost.Name;
                    item.ContentTypeId = blogPost.ContentTypeId;
                    item.Body          = TelligentService.FormatString100(Sitecore.StringUtil.RemoveTags(blogPost.Body.Raw));
                    item.AuthorUrl     = LinkManager.GetItemUrl(author);
                }
            }
            BlogPostsRepeater.DataSource = dataSource;
            BlogPostsRepeater.DataBind();
        }
コード例 #5
0
        protected void InitContent()
        {
            lnkSeeAll.NavigateUrl = LinkManager.GetItemUrl(Sitecore.Context.Database.GetItem(Constants.Pages.AllBlogs));

            if (IsUserLoggedIn)
            {
                var followedBlogs = TelligentService.GetFollowedBlogs(this.CurrentMember.ScreenName);

                string blogIds = string.Empty;

                foreach (var item in followedBlogs)
                {
                    blogIds = string.Format("{0}{1},", blogIds, Constants.BlogIds[item.Title]);
                }

                var    dataSource   = new List <BlogPost>();
                string temp         = string.Empty;
                var    blogPostList = TelligentService.ListBlogPosts(blogIds, "100");
                foreach (var item in blogPostList)
                {
                    if (!item.BlogName.Equals(temp))
                    {
                        dataSource.Add(item);
                        temp = item.BlogName;
                    }
                    if (dataSource.Count == 2)
                    {
                        break;
                    }
                }
                foreach (var item in dataSource)
                {
                    var sitecoreId = string.Empty;
                    if (item.Title.Contains("{"))
                    {
                        string[] s = item.Title.Split('{');
                        item.Title = s[0];
                        sitecoreId = "{" + s[1];
                    }
                    else
                    {
                        string[] s = item.Body.Split('<');
                        sitecoreId = s[0];
                    }
                    if (!sitecoreId.IsNullOrEmpty())
                    {
                        BlogsPostPageItem blogPost = Sitecore.Context.Database.GetItem(sitecoreId);
                        item.Body = TelligentService.FormatString160(blogPost.Body);

                        try
                        {
                            item.Author = Sitecore.Context.Database.GetItem(blogPost.Author.Raw)["Name"];
                        }
                        catch (Exception)
                        { }

                        item.ItemUrl   = blogPost.GetUrl();
                        item.AuthorUrl = LinkManager.GetItemUrl(Sitecore.Context.Database.GetItem(blogPost.Author.Raw));
                    }
                }
                rptBlogCards.DataSource = dataSource;
                rptBlogCards.DataBind();
            }
        }