Blog Listing with description

Posted by Community Admin on 03-Aug-2018 15:21

Blog Listing with description

All Replies

Posted by Community Admin on 13-Mar-2012 00:00

I couldn't add description for my blog.When i added it and save , it does not showing any error but the description not added to my blog.When i took it again it is gone...

Also i have to list the blogs with description and read more button
or
Can i show the blog and the first post in a blog in blog listing?

Please help.............An image file is attached with this and that is the way i want to look like my blog...

Posted by Community Admin on 16-Mar-2012 00:00

Hi Vinu,

Thank you for reporting this problem.

Usually, you are able to modify the templates of our widgets, so you can add the Description field to the glos list template and this way display Blogs and their description. Unfortunately, It seems that there's a bug with the Description custom field for Blogs. Please excuse us for the inconvenience. This improper behavior has been logged as a bug the system, which we'll fix for our future releases. You can track its status, following the PITS link.

As for your requirement to have blog posts together with the name of the blog they belong to, you need to map the template for the blog posts widget. I've made a sample for you. In the template I've added a hyperlink, which displays the name of the Blog each blog post is part of, and also points to the default page for this blog. Here the template:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="CustomTempBlogPosts.ascx.cs" Inherits="SitefinityWebApp.Controls.CustomTempBlogPosts" %>
<%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI.ContentUI" Assembly="Telerik.Sitefinity" %>
<%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI.Comments" Assembly="Telerik.Sitefinity" %>
<%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI" Assembly="Telerik.Sitefinity" %>
<%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI.PublicControls.BrowseAndEdit" Assembly="Telerik.Sitefinity" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<%@ Import Namespace="Telerik.Sitefinity" %>   
 
<telerik:RadListView ID="Repeater" ItemPlaceholderID="ItemsContainer"
    runat="server" EnableEmbeddedSkins="false" EnableEmbeddedBaseStylesheet="false"
    onitemdatabound="Repeater_ItemDataBound">
    <LayoutTemplate>
        <sf:ContentBrowseAndEditToolbar ID="MainBrowseAndEditToolbar" runat="server" Mode="Add"></sf:ContentBrowseAndEditToolbar>
        <ul class="sfpostsList sfpostListTitleDateContent">
            <asp:PlaceHolder ID="ItemsContainer" runat="server" />
        </ul>
    </LayoutTemplate>
    <ItemTemplate>
        <li class="sfpostListItem">
             
            <h2 class="sfpostTitle">
            <asp:HyperLink runat="server" ID="pageLink" ></asp:HyperLink>
                <sf:DetailsViewHyperLink ID="DetailsViewHyperLink1" TextDataField="Title" ToolTipDataField="Description" runat="server" />
            </h2>
             
            <div class="sfpostAuthorAndDate">
                <asp:Literal ID="Literal2" Text="<%$ Resources:Labels, By %>" runat="server" />
                <sf:PersonProfileView ID="PersonProfileView1" runat="server" />
                <sf:FieldListView ID="PostDate" runat="server" Format=" | PublicationDate.ToLocal():MMM dd, yyyy" />
            </div>
 
            <sf:FieldListView ID="PostContent" runat="server" Text="0" Properties="Content" WrapperTagName="div" WrapperTagCssClass="sfpostContent" />
 
            <sf:CommentsBox ID="itemCommentsLink" runat="server" CssClass="sfpostCommentsCount"/>
             
            <%--
            <div class="sfpostCategoriesAndTagsWrp">
                <sitefinity:HierarchicalTaxonField ID="HierarchicalFieldControl" DisplayMode="Read" BindOnServer="true" runat="server" TaxonomyId="E5CD6D69-1543-427b-AD62-688A99F5E7D4" WebServiceUrl="~/Sitefinity/Services/Taxonomies/HierarchicalTaxon.svc" Expanded="false" TaxonomyMetafieldName="Category" Title="Categories" ResourceClassId="TaxonomyResources" HideWhenNoTaxaFound="true" CssClass="sfpostCategoriesWrp" />
                <sitefinity:FlatTaxonField ID="FlatFieldControl" DisplayMode="Read" BindOnServer="true" runat="server" TaxonomyId="CB0F3A19-A211-48a7-88EC-77495C0F5374" WebServiceUrl="~/Sitefinity/Services/Taxonomies/FlatTaxon.svc" Expanded="false" TaxonomyMetafieldName="Tags" Title="Tags" ResourceClassId="TaxonomyResources" HideWhenNoTaxaFound="true" CssClass="sfpostTagsWrp" />
            </div>
            --%>
            <sf:ContentBrowseAndEditToolbar ID="BrowseAndEditToolbar" runat="server" Mode="Edit,Delete,Unpublish"></sf:ContentBrowseAndEditToolbar>
        </li>
    </ItemTemplate>
</telerik:RadListView>
<sf:Pager id="pager" runat="server"></sf:Pager>
<asp:PlaceHolder ID="socialOptionsContainer" runat="server" />
And this is the code-behind:
namespace SitefinityWebApp.Controls
    public partial class CustomTempBlogPosts : System.Web.UI.UserControl
    
        protected void Page_Load(object sender, EventArgs e)
        
            Repeater.ItemDataBound += new EventHandler<Telerik.Web.UI.RadListViewItemEventArgs>(Repeater_ItemDataBound);
        
 
        protected void Repeater_ItemDataBound(object sender, Telerik.Web.UI.RadListViewItemEventArgs e)
        
            
 
            switch (e.Item.ItemType)
            
                case RadListViewItemType.DataItem:
                case RadListViewItemType.AlternatingItem:
                    RadListViewDataItem item = e.Item as RadListViewDataItem;
                    if (item != null)
                    
                        var dataItem = item.DataItem as BlogPost;
                        var myLink = e.Item.FindControl("pageLink") as HyperLink;
                        string parentName = dataItem.Parent.Title.ToString();
                        var blog = App.WorkWith().Blogs().Where(b => b.Title == parentName).Get().SingleOrDefault();
                        var defaultBlogId = blog.DefaultPageId.ToString();
                        var defaultPage = App.WorkWith().Page(Guid.Parse(defaultBlogId)).Get().Page;
                        string BlogUrl = "~/" + defaultPage.Title.ToString();
                        myLink.Text = parentName;
                        myLink.NavigateUrl = BlogUrl;
                    
                    break;
            
            
        
    
Add these to an ascx. page. Then go to Administration -> Settings- >Controls -> Viewmap and create a new instance with the following fields:
HostType:Telerik.Sitefinity.Modules.Blogs.Web.UI.Public.MasterPostsView
LayoutTemplatePath: Relative path to your template
Keep in mind that in order to have a link to the default blog page, you have to set this when creating a Blog.

Hope you find this information useful. Let me know if you need additional assistance.

All the best,
Jen Peleva
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 24-May-2012 00:00

Hi, 

How can I do the same in SF5?

Regards.

Posted by Community Admin on 25-May-2012 00:00

Thanks Mr.Jen Peleva.....I done that in another way...But i think i can do it another project when it comes ...Is this corrected in Sitefinity 5.0? 
Anyway thanks again for your response....

Posted by Community Admin on 25-May-2012 00:00

<asp:Repeater ID="BlogListRepeater" runat="server">
    <ItemTemplate>
        <asp:HyperLink runat="server" ID="BlogLink">
            <div style="border1px solid #654">
                <asp:Label ID="title"><%# Eval("Title"%></asp:Label>
                <asp:Label ID="Label1"><%# Eval("UrlName"%></asp:Label>
            </div>
        </asp:HyperLink>
    </ItemTemplate>
</asp:Repeater>

 
 

        protected void Page_Load(object sender, EventArgs e)
        
            IQueryable<Blog> blogs = App.WorkWith().Blogs().Get();
            BlogListRepeater.DataSource = blogs;
            BlogListRepeater.ItemDataBound += BlogListRepeaterDataBound;
            BlogListRepeater.DataBind();
        
 
        private void BlogListRepeaterDataBound(object sender, RepeaterItemEventArgs e)
        
            if (e.Item.DataItem == null)
            
                return;
            
 
            var blogLink = (HyperLink)e.Item.FindControl("BlogLink");
            Blog blog = (Blog) e.Item.DataItem;
            if (blog.DefaultPageId != null)
            
                var p = App.WorkWith().Page((Guid)blog.DefaultPageId).Get();
                blogLink.NavigateUrl = "~/" + p.UrlName.Value;
            
 
        

This thread is closed