Trailing on the lead from Chris Blankenship and his singlepost user control, I created a multi-post user control. I’ve never been quite satisfied with the results of the recent posts control and Chris’s control filled in enough gaps for me to pursue this further.
I happen to keep my custom controls in /UserCustom instead of /UserControls. That way, I know these controls are not Blog Engine.Net controls and won’t need to be merged in the future.
Example
[ usercontrol: ~/UC/ItemList.ascx ShowDescription=true; Count=3;
ShowContent=false; ShowAuthor=false; ShowDate=false; ShowTitle=true;
ContentLength=120; CategoryList=photography; DateFormat={0:MM/dd/yyyy};]
Usage from ASP
<%@ Register src="../../UserCustom/MultiPosts.ascx" tagname="MultiPosts" tagprefix="uc7" %>
<uc7:MultiPosts ID="MultiPosts1" runat="server"
CategoryList="photography"
ContentLength="120"
Count="3"
DateFormat="{0:MM/dd/yyyy}"
ShowAuthor="false"
ShowContent="true"
ShowDate="false"
ShowDescription="true"
ShowTitle="true" />
Usage in Posts or Pages
Remove the space between the bracket and the word usercontrol.
[ usercontrol: ~/UserCustom/MultiPosts.ascx
ShowDescription=true;
Count=3;
ShowContent=false;
ShowAuthor=true;
ShowDate=true;
ShowTitle=true;
ContentLength=360;
CategoryList=photography;
DateFormat={0:MM/dd/yyyy}; ]
Post.cs Add AuthorAbsoluteLink
In order to reduce some of the clutter in the ASCX control template, I created a new property on the Post object to display the Authors link. If you want to stay with the mainline BE code base, you’ll need to modify the ASCX to set the asp:Hyperlink for AuthorLink to the code shown below.
public Uri AuthorAbsoluteLink
{
get
{
string authorLink = Utils.RemoveIllegalCharacters(Author);
authorLink = Utils.RelativeWebRoot + "author/" + HttpContext.Current.Server.UrlEncode(authorLink) + BlogSettings.Instance.FileExtension;
return Utils.ConvertToAbsolute(authorLink);
}
}