Add an Authors List

Topics: ASP.NET 2.0, Themes
May 11, 2009 at 8:05 PM

How do I add an authors list to the right panel/side bar? Where Do I edit the right panel / side bar?

May 14, 2009 at 3:00 PM

You can add the AuthorList control on you master page using the following code. 

<blog:AuthorList runat="server" ID="Contributor"></blog:AuthorList>

Author List control can be modified my making changes in App_Code/Controls/AuthorList.cs

You can set the fomating of control in this file and create css in you theme. 

Thansk,

Usman

May 20, 2009 at 4:07 PM
Edited May 20, 2009 at 4:14 PM

Hi

Is it possible to add Author as a item in the dropdown as per the others i.e. recent posts etc.

The dropdown was displayed after the user login as a admin.

So admin can add Author as a spearate panel from the dropdown.

I am using 1.4.5 version of blogengine.net

Thanks in advance.

 

Mar 4, 2011 at 8:20 PM

I'm not sure if this is still a relevant question since it was created so long ago, but in order to add the AuthorList section to the panel as a dropdown option, you need to create a new widget.  Create a new folder in the widgets folder called 'AuthorList' and make a user control in that folder called 'widget.ascx'.  You then need to add the AuthorList item to the user control as such:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="widget.ascx.cs" Inherits="Widgets.AuthorList.Widget" %>
<blog:AuthorList ID="AuthorList1" runat="Server" />

(in this example I changed the default namespace to Widgets.AuthorList)

Then in the codebehind the usercontrol, the file will need to look like this:

// --------------------------------------------------------------------------------------------------------------------
// <summary>
//   The widget.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Widgets.AuthorList
{
    using App_Code.Controls;
    using BlogEngine.Core;

    /// <summary>
    /// The widget.
    /// </summary>
    public partial class Widget : WidgetBase
    {
        #region Properties

        /// <summary>
        /// Gets a value indicating whether or not the widget can be edited.
        /// <remarks>
        /// The only way a widget can be editable is by adding a edit.ascx file to the widget folder.
        /// </remarks>
        /// </summary>
        /// <value></value>
        public override bool IsEditable
        {
            get
            {
                return false;
            }
        }

        /// <summary>
        /// Gets the name. It must be exactly the same as the folder that contains the widget.
        /// </summary>
        /// <value></value>
        public override string Name
        {
            get
            {
                return "AuthorList";
            }
        }

        #endregion

        #region Public Methods

        /// <summary>
        /// This method works as a substitute for Page_Load. You should use this method for
        /// data binding etc. instead of Page_Load.
        /// </summary>
        public override void LoadWidget()
        {
            // Nothing to load
        }

        #endregion
    }
}

It's not overly important that you name your widget 'AuthorList', but it IS important that the name of the folder and public string override Name in the codebehind are the same, or BlogEngine won't be able to load the usercontrol if you change the title of the panel after you add it to your site.

If you get stuck, you can always use the other widgets as an example.  However, be careful that you pay attention to the LoadWidget() function.  In the Administration widget, it has a check to make sure the widget won't appear for anyone who is not authenticated (aka, who is not an administrator). Example is below.

/// <summary>
        /// This method works as a substitute for Page_Load. You should use this method for
        /// data binding etc. instead of Page_Load.
        /// </summary>
        public override void LoadWidget()
        {
            this.Visible = Security.IsAuthenticated;
        }