Dave Burke : Freelance .NET Web Developer specializing in Online Communities

First Sueetie Smart Placeholder Control Surfaces

When I was initially contemplating how to restrict Sueetie blog comments to Registered Users I thought I'd use a smart placeholder control to display or hide the comment form.  While I went another route on blog comments, the Sueetie UserRolePlaceHolder took form as a very useful control, the first of several Sueetie "smart" PlaceHolders we'll no doubt be seeing. 

To demonstrate the UserRolePlaceHolder I added a simple welcome greeting to registered users on the Sueetie.org home page.  By contrast, anonymous users don't see the message.


 

As I've said a number of times, simplicity is the cornerstone of Sueetie architecture, and I think it's exemplified in the new UserRolePlaceHolder control.  First of all, the placeholder, like Sueetie placeholders to come, will most likely be single-function with no guesswork on how to use them.  The UserRolePlaceHolder control displays or hides information based on, um, User Role.

To make the controls even easier to use, the property and content areas are full intellisense-enabled.  Here's a screenshot of setting the role.



Each placeholder control will contain a TrueContentTemplate and FalseContentTemplate for consistency.  Either a condition is true or it isn't, with options to display content on either condition.  Those, too, are intellisense-enabled.



True to the "Patterns and Origins" history of Sueetie architecture documentation, it's time to note that the UserRolePlaceHolder control was written from scratch.  Don't have any illusions, Chameleon is brilliant, but it's the LAST thing we want in Sueetie.  The full control source is displayed below. You'll have to admit that there are very few lines of code here. Definitely not Chameleon in origin.



The trick was instantiating the True and False ContentTemplates on a bound object, in this case the SueetieUser.  A post from Stefan Sedich describing his Templated ASP.NET RSS Feed Reader Control was very helpful in understanding the concepts involved.  Highly recommended.  There are also examples of templating in YetAnotherForum.NET, particularly in the YAF.Controls project Container control.  Templating is also used in Joe Shearn's Sueetie Content Parts control source.

Look for more Sueetie conditional placeholders in the weeks to come as the need arises.  We'll try to keep them as simple to use as UserRolePlaceHolder.

Comments (0) | Post RSS RSS comment feed

Posted on 7/4/2009 1:13:46 PM by Dave Burke
Categories: Sueetie | .NET
Tags: No tags for this post

Related posts

Comments are closed

This site was built with the Sueetie .NET Open Source Community Framework. Learn more about Sueetie at Sueetie.com.