+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / External Template for BlogsNewBlogView

External Template for BlogsNewBlogView

12 posts, 0 answered
  1. Saumitra
    Saumitra avatar
    127 posts
    Registered:
    10 Mar 2009
    09 Nov 2010
    Link to this post
    Hi,

    I wish to change the UI for BlogsNewBlogView control as per my requirements. But I was unable to find an external template for the same. Please help.

    I'm using Sitefinity 3.7 Standard Edition SP1

    Thanks,
    Saumitra
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    09 Nov 2010
    Link to this post
    Hi Saumitra,

    The template you have to us is "BlogsListView.ascx". This template is used by a custom control - BlogEditor that is used when you try to create a new blog.

    All the best,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Saumitra
    Saumitra avatar
    127 posts
    Registered:
    10 Mar 2009
    09 Nov 2010
    Link to this post
    Hi Ivan,

    I had a look at the template mentioned by you. But that is not what I'm looking for, as it internally again uses the blogEditor custom control. I wanted to know which is the external template that the blogEditor control itself uses internally.

    My requirement is that I need to place some additional inputs in that control for creating a new Blog.

    Thanks,
    Saumitra
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    09 Nov 2010
    Link to this post
    Hello Saumitra,

    1. Take a look at this post.

    2. Below is the html of the  template that is used by BlogEditor control

    <%@ Control Language="C#" %>
    <div class="simple expandnew">
    <fieldset class="set">
    <div class="setIn clearfix">
        <h3 id="createBlogTitle"><asp:Literal runat="server" Text="CreateBlogTitle"></asp:Literal></h3>
        <ol>
            <li>
                <asp:Label ID="lblBlogName" runat="server" Text="BlogName" AssociatedControlID="blogNameText"></asp:Label>
                <asp:TextBox ID="blogNameText" runat="server" ValidationGroup="blogSettings" MaxLength="50"></asp:TextBox>
                <asp:RequiredFieldValidator ID="PageNameRequired" runat="server" ValidationGroup="blogSettings" Display="Dynamic" ControlToValidate="blogNameText" CssClass="validMessage"><strong><asp:Literal runat="server" Text="BlogNameEmpty"></asp:Literal></strong></asp:RequiredFieldValidator>
            </li>
            <li class="choosePost clearfix">
                <asp:Label ID="lblBlogPage" runat="server" Text="BlogPage" AssociatedControlID="blogPageText"></asp:Label>
                <asp:TextBox ID="blogPageText" runat="server" ValidationGroup="blogSettings" MaxLength="100"></asp:TextBox>
                <asp:LinkButton runat="server" ID="selectBlogPage" Text="Select" CssClass="picker"></asp:LinkButton>
                <asp:RequiredFieldValidator ID="BlogPageNameRequired" runat="server" ValidationGroup="blogSettings" Display="Dynamic" ControlToValidate="blogPageText" CssClass="validMessage">
                    <strong><asp:Literal ID="Literal1" runat="server" Text="BlogPageEmpty"></asp:Literal></strong>
                </asp:RequiredFieldValidator>
            </li>
            <li>
                <asp:Label ID="lblBlogDescription" runat="server" Text="Description" AssociatedControlID="blogDescriptionText"></asp:Label>
                <asp:TextBox ID="blogDescriptionText" runat="server" TextMode="MultiLine"></asp:TextBox>
            </li>
            <li>
                <asp:Label ID="Label1" runat="server" AssociatedControlID="blogAuthorText" Text="BlogAuthor"></asp:Label>
                <asp:TextBox ID="blogAuthorText" runat="server" MaxLength="50" TextMode="multiLine"></asp:TextBox>
            </li>
        </ol>
        <p class="button_area">
            <asp:LinkButton ID="createBlogButton" runat="server" ValidationGroup="blogSettings" CssClass="CmsButLeft okdark"><strong class="CmsButRight dark"><asp:Literal runat="server" Text="CreateThisBlog"></asp:Literal></strong></asp:LinkButton>
            <span><asp:Literal runat="server" Text="Or"></asp:Literal></span>
            <asp:LinkButton ID="cancelCreateBlogButton" runat="server" Text="Cancel" CssClass="cmscclcmd"></asp:LinkButton>       
        </p>
     </div>
    </fieldset>
    <div class="bottom"><div><!-- --></div></div>
    </div>


    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Saumitra
    Saumitra avatar
    127 posts
    Registered:
    10 Mar 2009
    10 Nov 2010
    Link to this post
    Hi Ivan,

    This is getting a little confusing for me. I'll explain what i've done so far, step by step:

    1) I created a class in the App_Code folder that inherited BlogEditor class and overridden the Container property. Following is the code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Telerik.Blogs.WebControls;
    using Telerik.Cms.Web.UI;
    using System.Web.UI;
    using Telerik.Framework.Web;
      
    namespace TicketPlease.Blogs
    {
        /// <summary>
        /// Summary description for BlogEditorCustom
        /// </summary>
        public class BlogEditorCustom : Telerik.Blogs.WebControls.BlogEditor
        {
            public BlogEditorCustom()
            {
                //
                // TODO: Add constructor logic here
                //
            }
            protected override void CreateChildControls()
            {
                base.CreateChildControls();
            }
      
            protected override Telerik.Cms.Web.UI.GenericContainer Container
            {
                get
                {
                    this.container = new GenericContainer();
                    string templateName = (this.BlogId == Guid.Empty)
                                                      ? BlogEditorCustom.NewBlogTemplateName
                                                      : BlogEditorCustom.BlogSettingsTemplateName;
                    ITemplate layoutTemplate = ControlUtils.GetTemplate(null, templateName, GetType(), GetType(), this.GetType(), this.ProviderName);
                    layoutTemplate.InstantiateIn(this.container);
                    return base.Container;
                }
            }
      
            private GenericContainer container;
      
            private const string NewBlogTemplateName = "~/Sitefinity/Admin/ControlTemplates/Blogs/BlogCustomControl.ascx";
            private const string BlogSettingsTemplateName = "~/Sitefinity/Admin/ControlTemplates/Blogs/BlogCustomControl.ascx";
      
        }
    }

    2) I created a usercontrol to be used as a template that resides in the path mentioned in the above code. Following is the HTML for that usercontrol:
    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="~/Sitefinity/Admin/ControlTemplates/Blogs/BlogCustomControl.ascx.cs" Inherits="Sitefinity_Admin_ControlTemplates_Blogs_BlogCustomControl" %>
      
    <div class="simple expandnew">
    <fieldset class="set">
    <div class="setIn clearfix">
        <h3 id="createBlogTitle"><asp:Literal ID="Literal1" runat="server" Text="CreateBlogTitle"></asp:Literal></h3>
        <ol>
            <li>
                <asp:Label ID="lblBlogName" runat="server" Text="BlogName" AssociatedControlID="blogNameText"></asp:Label>
                <asp:TextBox ID="blogNameText" runat="server" ValidationGroup="blogSettings" MaxLength="50"></asp:TextBox>
                <asp:RequiredFieldValidator ID="PageNameRequired" runat="server" ValidationGroup="blogSettings" Display="Dynamic" ControlToValidate="blogNameText" CssClass="validMessage"><strong><asp:Literal ID="Literal2" runat="server" Text="BlogNameEmpty"></asp:Literal></strong></asp:RequiredFieldValidator>
            </li>
            <li class="choosePost clearfix">
                <asp:Label ID="lblBlogPage" runat="server" Text="BlogPage" AssociatedControlID="blogPageText"></asp:Label>
                <asp:TextBox ID="blogPageText" runat="server" ValidationGroup="blogSettings" MaxLength="100"></asp:TextBox>
                <asp:LinkButton runat="server" ID="selectBlogPage" Text="Select" CssClass="picker"></asp:LinkButton>
                <asp:RequiredFieldValidator ID="BlogPageNameRequired" runat="server" ValidationGroup="blogSettings" Display="Dynamic" ControlToValidate="blogPageText" CssClass="validMessage">
                    <strong><asp:Literal ID="Literal3" runat="server" Text="BlogPageEmpty"></asp:Literal></strong>
                </asp:RequiredFieldValidator
            </li>
            <li>
                <asp:Label ID="lblBlogDescription" runat="server" Text="Description" AssociatedControlID="blogDescriptionText"></asp:Label>
                <asp:TextBox ID="blogDescriptionText" runat="server" TextMode="MultiLine"></asp:TextBox>
            </li>
            <li>
                <asp:Label ID="Label1" runat="server" AssociatedControlID="blogAuthorText" Text="BlogAuthor"></asp:Label>
                <asp:TextBox ID="blogAuthorText" runat="server" MaxLength="50" TextMode="multiLine"></asp:TextBox>
            </li>
        </ol>
        <p class="button_area">
            <asp:LinkButton ID="createBlogButton" runat="server" ValidationGroup="blogSettings" CssClass="CmsButLeft okdark"><strong class="CmsButRight dark"><asp:Literal ID="Literal4" runat="server" Text="CreateThisBlog"></asp:Literal></strong></asp:LinkButton>
            <span><asp:Literal ID="Literal5" runat="server" Text="Or"></asp:Literal></span>
            <asp:LinkButton ID="cancelCreateBlogButton" runat="server" Text="Cancel" CssClass="cmscclcmd"></asp:LinkButton>        
        </p>
     </div>
    </fieldset>
    <div class="bottom"><div><!-- --></div></div>
    </div>

    3) In the BlogsListView.ascx usercontrol, I referred to the new control as following:
    <%@ Control Language="C#" %>
    <%@ Register TagPrefix="sf" Namespace="Telerik.Cms.Web.UI" Assembly="Telerik.Cms.Web.UI" %>
    <%@ Register TagPrefix="sf" Namespace="Telerik.Blogs.WebControls" Assembly="Telerik.Blogs" %>
    <%@ Register TagPrefix="uc1" Namespace="TicketPlease.Blogs" Assembly="App_Code"  %>
      
    <uc1:BlogEditorCustom ID="BlogEditor" runat="server" />
    <div class="ToolsAll">
        <asp:HyperLink ID="createNewButton" runat="server" cssClass="CmsButLeft new"><asp:Literal runat="server" Text="<%$Resources:CreateBlog %>"></asp:Literal></asp:HyperLink>
        <asp:PlaceHolder ID="fullWindow" runat="server">
        </asp:PlaceHolder>
        <div class="clear"><!-- --></div>
    </div>
    <div class="workArea">
    <sf:MessageControl runat="server" ID="message">
        <ItemTemplate>
            <asp:Label runat="server" ID="messageText"></asp:Label>
        </ItemTemplate>
    </sf:MessageControl>
    <h2 class="gridTitle"><asp:Literal runat="server" ID="title" Text="<%$Resources:Blogs %>"></asp:Literal></h2>
    <asp:GridView ID="GridView1" AllowPaging="true" AllowSorting="true" PageSize="20" AutoGenerateColumns="false" GridLines="none" CssClass="listItems" runat="server">
        <Columns>
            <asp:ButtonField ButtonType="Link" CommandName="Delete" Text="<%$Resources:Delete %>"><ItemStyle CssClass="gridActions delete" /></asp:ButtonField>         
            <asp:ButtonField ButtonType="Link" CommandName="OpenBlog" DataTextField="Name" SortExpression="Name" HeaderText="<%$Resources:Name %>"><ItemStyle CssClass="gridContentTitle" /></asp:ButtonField>
            <asp:BoundField DataField="Owner" HeaderText="<%$Resources:Owner %>" SortExpression="Owner" />
            <asp:BoundField DataField="DateCreated" HeaderText="<%$Resources:Created %>" DataFormatString="<%$Resources:CreatedDateFormat %>" HtmlEncode="false" SortExpression="DateCreated" />
            <asp:ButtonField DataTextField="DynamicPostCount" HeaderText="<%$Resources:Posts %>" CommandName="OpenBlog" />
            <asp:ButtonField DataTextField="CommentsCount" HeaderText="<%$Resources:Comments %>" CommandName="ShowComments" />
            <asp:ButtonField ButtonType="Link" CommandName="ChangeSettings" Text="<%$Resources:ChangeSettings %>" HeaderText="<%$Resources:Settings %>"></asp:ButtonField>
        </Columns>
    </asp:GridView>
    <asp:PlaceHolder ID="emptyWindow" runat="server">
    <div id="empty">
        <h2 class="gridTitle"><asp:Literal runat="server" Text="<%$Resources:NoBlogs %>"></asp:Literal></h2>
        <p><asp:HyperLink ID="createNewEmpty" runat="server" cssClass="mainLink" ToolTip="<%$Resources:CreateFirstBlogTooltip %>"><strong><asp:Literal runat="server" Text="<%$Resources:CreateYourFirstBlog %>"></asp:Literal></strong></asp:HyperLink><br />
        <asp:Literal runat="server" Text="<%$Resources:Or %>"></asp:Literal>, <a href="http://www.sitefinity.com/sf3/faq.html#ab" target="_blank"><asp:Literal runat="server" Text="<%$Resources:CheckBlogsFAQ %>"></asp:Literal></a></p>       
    </div>
    </asp:PlaceHolder>
    </div>

    After following these steps when I run the application I get an error that I've attached as a screenshot.

    Please help.

    Thanks,
    Saumitra
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    10 Nov 2010
    Link to this post
    Hi Saumitra,

    You have to set the first parameter of ControlUtils.GetTemplate

    ITemplate layoutTemplate = ControlUtils.GetTemplate(templateName, null, GetType(), GetType(), this.GetType(), this.ProviderName);

    which is the virtual path of the template.

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Saumitra
    Saumitra avatar
    127 posts
    Registered:
    10 Mar 2009
    10 Nov 2010
    Link to this post
    Hi Ivan,

    I did that. But more or less the error is still the same. Please refer the screenshot attached.

    Thanks,
    Saumitra
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    10 Nov 2010
    Link to this post
    Hi Saumitra,

    You should not call the base.Container inside Container property

    namespace Telerik.Samples
    {
        public class BlogEditorCustom : Telerik.Blogs.WebControls.BlogEditor
        {
     
            protected override void CreateChildControls()
            {
                base.CreateChildControls();
            }
     
            protected override Telerik.Cms.Web.UI.GenericContainer Container
            {
                get
                {
                    this.container = new GenericContainer();
                    string templateName = (this.BlogId == Guid.Empty)
                                                      ? BlogEditorCustom.NewBlogTemplateName
                                                      : BlogEditorCustom.BlogSettingsTemplateName;
                    ITemplate layoutTemplate = ControlUtils.GetTemplate(templateName, null, this.GetType(), this.GetType(), this.GetType(), this.ProviderName);
                    layoutTemplate.InstantiateIn(this.container);
                   //return base.Container;
                    return this.container;
                }
            }
     
            private GenericContainer container;
     
            private const string NewBlogTemplateName = "~/Sitefinity/Admin/ControlTemplates/Blogs/BlogEditor.ascx";
            private const string BlogSettingsTemplateName = "~/Sitefinity/Admin/ControlTemplates/Blogs/BlogSettingsView.ascx";
     
        }
    }

    but in this case you should implement the commands of the buttons.

    All the best,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  9. Saumitra
    Saumitra avatar
    127 posts
    Registered:
    10 Mar 2009
    11 Nov 2010
    Link to this post
    Hi Ivan,

    I would definitely try the solution. But in the meanwhile I wanted to know something else. Actually my requirement is that along with the regular blog inputs, I wish to add some more inputs to the UI which would add some more details but in custom tables in the database. So I would like to customise the template but at the same time let Sitefinity handle the functionality of creating the blog. I would just like to add the code that adds those additional details in my custom tables for that blog.

    How do I achieve that?

    Thanks,
    Saumitra
  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    11 Nov 2010
    Link to this post
    Hello Saumitra,

    1. Modify the HTML of the BlogEditor.ascx template - used when you create a new blog and BlogSettingsView.ascx used when you edit an existing blog.

    2. To get/set your custom data you can use OpenAccess ORM, LINQ -SQL or another data layer.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  11. Saumitra
    Saumitra avatar
    127 posts
    Registered:
    10 Mar 2009
    11 Nov 2010
    Link to this post
    Hi Ivan,

    But didn't you mention that If I use BlogEditor.ascx as my template, I will have to implement the commands of the buttons. What I understand from that is I'll have to handle the blog creation functionality too, which I do not want to do. I want Sitefinity to handle the blog creation, then give me the ContentID that is newly created, so that I can further save the additional input data to the custom tables.

    Please correct my understanding if its wrong.

    Thanks,
    Saumitra
  12. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    11 Nov 2010
    Link to this post
    Hi Saumitra,

    The logic for creating a blog should be implemented when you do not call the base.Container. BlogEditor is not supposed to work with external templates and this is why there are not in the ExternalTempaltes archive we ship and there is no mapping for these templates. You can use Generic Content API to manage blogs



    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Register for webinar
12 posts, 0 answered