#1
Hello

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?
Topic Starter
  • johans
  • Rank: YAF Lover
  • Reputation:
    Neutral
    51.8%
  • Joined: 05/06/2012
  • Posts: 42
  • Thanks: 1 times
  • Was thanked: 1 time(s) in 1 post(s)
#2
Johans,

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,
Dave

http://sueetie.com 
daveburke attached the following image(s):
yaf0716.png
  • daveburke
  • Rank: YAF All-the-Time
  • Reputation:
    Exalted
    100%
  • Medals:
    Medal of Honor Key: Given to pillars of the community who are key players in the YAF community and project.Medal of Open Source Contributer: Given to Dave for creating the Sueetie Open Source Project.Medal of Honor Thumbs Up!: Given to community members who are doing very cool things with the YAF project.
  • Joined: 28/05/2008
  • Posts: 148
  • Thanks: 23 times
  • Was thanked: 19 time(s) in 16 post(s)
#3
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...
			output.WriteLine(userBox);

			output.WriteLine("</div>"😉;
		}

		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>
		[NotNull]
		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;
		}
	}
}
Topic Starter
  • johans
  • Rank: YAF Lover
  • Reputation:
    Neutral
    51.8%
  • Joined: 05/06/2012
  • Posts: 42
  • Thanks: 1 times
  • Was thanked: 1 time(s) in 1 post(s)
Forum Jump  
  • You cannot post new topics in this forum.
  • You cannot reply to topics in this forum.
  • You cannot delete your posts in this forum.
  • You cannot edit your posts in this forum.
  • You cannot create polls in this forum.
  • You cannot vote in polls in this forum.

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