•  johans
  • 51.8% (Neutral)
  • YAF Lover Topic Starter

I want to add controls in the UserBox control, but i'd rather not change the code in YAF.Controls.UserBox (To be safe when upgrading). Is there such a way?

You're absolutely correct in not wanting to touch the UserBox Control directly in YAF.Controls. We customize UserBox and a few other YAF Controls in Sueetie, as well as do some other customization so we use a separate Sueetie.Forums class which references YAF.Classes.Config, YAF.Classes.Data, YAF.Core, YAF.Types and YAF.Utils. Then we can use code excerpts from various YAF projects as needed.

You can download the Sueetie Open Source Solution called Atomo if you want to see how we're doing it. Attached is a screenshot of our Sueetie.Forums class project in Visual Studio.

Good luck,
daveburke attached the following image(s):
  •  johans
  • 51.8% (Neutral)
  • YAF Lover Topic Starter
Thanks for the tip.

I ended up with doing:

	public class GTKUserBox : UserBox {
		public const string CharacterInformation = @"<yaf:characterinformation\s*/>";
		protected override void Render(HtmlTextWriter output) {
			output.WriteLine(@"<div class=""yafUserBox"" id=""{0}"">".FormatWith(ClientID));

			string userBox = CachedUserBox;
			if (string.IsNullOrEmpty(userBox)) {
				userBox = CreateUserBoxContents();
				// cache...
				CachedUserBox = userBox;

			// output the user box info...


		protected string CreateUserBoxContents() {
			string userBox = CreateUserBox();

			// Character information
			userBox = MatchUserBoxCharacterInfo(userBox);

			return userBox;

		/// <summary>
		/// 	The match user box character information.
		/// </summary>
		/// <param name="userBox"> The user box. </param>
		/// <returns> String with Character Information string added to UserBox . </returns>
		private string MatchUserBoxCharacterInfo([NotNull] string userBox) {
			string filler = string.Empty;
			var rx = GetRegex(CharacterInformation);

			if (!DataRow["IsGuest"].ToType<bool>()) {
				filler = YafUser.GetCharacterInfo(UserId);

			// replaces template placeholder with actual character information
			userBox = rx.Replace(userBox, filler);

			return userBox;

About Us

The YAF.NET is an open source .NET forum project. YAF.NET is supported by an team of international developers who are build community by building community software.

Powered by Resharper Donate with PayPal button

Project Twitter Updates

Copyright © YetAnotherForum.NET & Ingo Herbote. All rights reserved