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

Forums / Developing with Sitefinity / Author Avatar in Blogs: BlogSettingsView

Author Avatar in Blogs: BlogSettingsView

5 posts, 0 answered
  1. Jodie
    Jodie avatar
    59 posts
    Registered:
    09 Oct 2012
    07 Jan 2010
    Link to this post
    Hi Guys,

    We are wanting to have an avatar for our blog authors, I have looked around and found this post:

    http://www.sitefinity.com/support/forums/sitefinity-3-x/developing-with-sitefinity/adding-image-to-blog-module.aspx

    However I would like to add the author image field to the Settings of the blog (BlogSettingsView) is this possible as I cannot seen to find the template for sf:BlogEditor.

    Any help is appreciated.

    Thanks

    Jodie
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    07 Jan 2010
    Link to this post
    Hi Jodie,

    1. Map blogPostsControlDesigner template

    <viewSettings hostType="Telerik.Blogs.WebControls.Design.BlogPostsDesigner"
                  layoutTemplatePath="~/Sitefinity/Admin/ControlTemplates/Blogs/BlogPostsControlDesigner.ascx" />

    2. Open the template for editing and add a new TextSetting
    sample

    <sf:TextSetting ID="TextSetting66"
    TargetID="Avatar"
    SettingTitle="Show/Hide Avatar"
    AllowLabelSetting="false"
    AllowFormatSetting="false"
    AllowVisibilitySetting="True"
    TargetVisibleByDefault="True">
    </sf:TextSetting>

    3. Drop BlogPosts control and you will noticed that a new TextSetting is shown Show/Hide Avatar.
    Note that the control has several Presentation Modes so you need to add the setting inside the desired PresentationMode.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Jodie
    Jodie avatar
    59 posts
    Registered:
    09 Oct 2012
    07 Jan 2010
    Link to this post
    Hi Ivan,

    Thanks for your reply, I don't think I have explained correctly. I have attached an image of the blog settings I am talking about. Also I would like the image selector to select the image.

    Cheers

    Jodie
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    08 Jan 2010
    Link to this post
    Hi Jodie,

    Here are the steps you have to follow.

    1. Map BlogSettingsView external template

    <viewSettings hostType="Telerik.Blogs.WebControls.Admin.BlogSettingsView" layoutTemplatePath="~/Sitefinity/Admin/ControlTemplates/Blogs/BlogSettingsView.ascx" />

    2. Create a custom class that inherits from BlogEditor
    - create a custom template for the BlogEditor
    - create a custom method where you get the save button from a Container and save, edit, cancel the changes

    sample

    private virtual void CreateNewBlogControls()
           {
               if (!String.IsNullOrEmpty(this.ProviderName))
               {
                   this.CreateBlogButton.Command += this.Button_Command;
                   this.CreateBlogButton.CommandName = "CreateNewBlog";
     
                   this.editorDialog = new PropertyEditorDialog();
                   this.editorDialog.TypeContainer = this;
                   this.editorDialog.PropertyChanged += this.editorDialog_PropertyChanged;
                   this.Controls.Add(this.editorDialog);
     
                   PropertyDescriptor desc = this.Properties.Find("BlogPage", false);
                   this.SelectBlogPage.CommandName = "Telerik.Cms.Web.UI.CmsUrlWebEditor, Telerik.Cms";
                   this.SelectBlogPage.CommandArgument = desc.Name;
                   this.SelectBlogPage.Command += this.SelectBlogPage_Command;
                   this.CancelCreateBlogButton.Command += this.Button_Command;
                   this.CancelCreateBlogButton.CommandName = "CancelCreateNewBlog";
               }
           }
    private void Button_Command(object sender, CommandEventArgs e)
           {
               switch (e.CommandName)
               {
                   case "CreateNewBlog":
                       CreateNewBlog();
                       break;
                   case "ChangeSettings":
                       ChangeSettings();
                       break;
                   case "CancelCreateNewBlog":
                       OnCanceled(EventArgs.Empty);
                       break;
               }
           }
     
           .....
             .....
    private void CreateNewBlog()
           {
               if (this.blog == null)
               {
                   this.blog = this.blogManager.CreateBlog();
                   this.blog.Name = this.BlogNameText.Text;
                   this.blog.Description = this.BlogDescriptionText.Text;
                   this.blog.BlogPage = "~/" + this.BlogPageText.Text.TrimStart( new[] { '/', '~' });
                   this.blog.Author = this.BlogAuthorText.Text;
                   this.blogManager.SaveBlog(blog);
                 // IMPLEMENT THE LOGIC FOR YOUR IMAGE SELECTOR
                 // HERE CREATE A PERSISTANCE CLASS TO SAVE THE DATA
                 // CREATE EVENT HANDLER TO SAVE THE DATA
               }
           }

    3. Replace <sf:BlogEditor id="blogEditor" runat="server"></sf:BlogEditor> control from the template BlogSettingsView with your custom control. Note that the ID should be the same

    <cc:BlogEditorCustom id="blogEditor" runat="server"></cc:BlogEditorCustom >


    The easiest way.

    1.  Create a new profile property for your user that will be owner of the blog.
    2. Map the external template - ListPageMaster.ascx
    3. Add image control to this template
    4. Create a custom class that inherits BlogPosts
    5. In this custom class create a string type property which will be used to set the Author Name.
      -- or just get the author for the selected blogs.
    6. User ProfileBase ASP.NET class to get the profile and set the ImageUrl of the Image control.

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. Jodie
    Jodie avatar
    59 posts
    Registered:
    09 Oct 2012
    12 Jan 2010
    Link to this post
    Hi Ivan,

    Thanks for your reply. I thought it may be a bit of a process to achieve this. The last suggestion you made 'the easiest way' is the approach I'll try.

    Thanks for you help

    Jodie 
Register for webinar
5 posts, 0 answered