Sueetie Favorite Changes in YetAnotherForum.NET 1.9.4

Sueetie has supported two types of YetAnotherForum.NET favorite content tagging for some time, Favorite Topics and Favorite Messages (individual posts.)  Revisiting Sueetie Forum content tagging was an opportunity to spend more time with the new and improved YetAnotherForum.NET 1.9.4 source.

Below is how Topic tagging worked in 1.9.3, where it was added to the thread’s "Options" menu.  You can see it in action at Sueetie Forums. Works great, but I wanted to expose the function a bit more in the UI.

 

The Message Tagging button as it currently functions works perfectly fine, too, but it probably shouldn’t be listed with the Author Contact buttons at the bottom of the post.

The coming Topic and Message Tagging button locations are shown below. Favorite Topic button circled in blue, Favorite Message button in red. Notice also the arrow to a new area on YAF messages which in the screenshot says, "2 users thanked testguy for this useful post" along with the names of those who thanked him.  This is YAF 1.9.4’s new "Thanks" feature, another community-enriching feature that people are going to love.

I’m going to focus on tagging message favorites, but before doing so I wanted to show you what happens when the "Tag Topic as Favorite" button is clicked.  A popup message appears and the button text changes to "Untag as Favorite."

Back to Message Tagging and the new YAF 1.9.4 Thanks feature.  One of the beauties of YetAnotherForum.NET is its interaction with users through dynamic client-side prompts, button text changes, and popup messages. To achieve that "YAF Standard of Interactive Excellence" I built the 1.9.3 Sueetie Tag Message function with AJAX calling a WCF Service.  On the screenshot two or three images earlier you saw how the message "You tagged this message by bitterSTAR as a favorite!" is displayed below the button. That’s cool, but for 1.9.4 I wanted to duplicate the logic of YAF’s new Thanks function.  I like it, both front end and back.

"Thanks" uses AjaxPro, a framework I haven’t used before. AjaxPro essentially provides a wrapper from client-side JavaScript to .NET classes. By walking through the logic of Thanks and AjaxPro I was able to create a completely new Tag Message Favorite function while watching Saturday morning cartoons.

In a nutshell, the Forum Message Tag process displays a "Tag" button, or if already a favorite, the "Untag" button. The button uses javascript to call a Sueetie.Forums Control Class through AjaxPro that performs the tagging or tag removal. The alternative javascript function code is returned and replaces the DOM ID element’s HTML. To be even more succinct, you click a button, something cool happens on the server, and the button flips text and function in an instant with no postback.

The technical highlights are numbered in the code images below.  1) AjaxPro registers the .NET class the javascript will be talking to, 2) the initial HTML javascript to populate the button ID element is created.

3 & 4) The javascript function in YAF’s JavaScriptBlock.cs class that talks to the Sueetie.Forums ForumFavorite class with AjaxPro is created and registered.

5) The Sueetie.Forums method is given the [AjaxPro.AjaxMethod] attribute, the favorite is created, and the "Untag" supporting button text is returned to the javascript code via AjaxPro. 

At this point the button HTML is updated, ready and waiting for the user to change his or her mind about the favorite message, where the process can be reversed, then reversed again.  "This is not my beautiful house!  This is not my beautiful wife!"

Article written by

A long time developer, I was an early adopter of Linux in the mid-90's for a few years until I entered corporate environments and worked with Microsoft technologies like ASP, then .NET. In 2008 I released Sueetie, an Online Community Platform built in .NET. In late 2012 I returned to my Linux roots and locked in on Java development. Much of my work is available on GitHub.