Welcome to the Sueetie News blog, where we provide you with the latest news and insider info on the Sueetie Online Community Platform. For tips in growing, managing and marketing your online community, visit our blog The Business of Community.

Going Mobile With YetAnotherForum.NET

by Dave Burke 15. July 2010 21:10

In this Sueetie Going Mobile Series post we’re going to look at how a mobile YetAnotherForum.NET came into being. You’ll find the Sueetie Wiki document on which this post was based located in the Sueetie Patterns and Origins area.

_________________ 

Extending YetAnotherForum.NET by Creating New Pages and Controls

To create a mobile version of YetAnotherForum.NET we added new pages and controls to remove and/or re-arrange elements to accommodate the reduced mobile display dimensions. Fortunately, YAF makes adding new pages and controls very easy.

Here is a screenshot of the new mobile pages and controls added to YAF.NET. (The controls and pages file list is abbreviated to focus on topic.)

Image 

The YetAnotherForum.NET ForumPages Enumerator

YetAnotherForum.NET uses a enumerator matching logic to determine page names. The enum class is in the YAF.Classes.Config project and is named "ForumPages." The page names match the enumerator constant name. Here's an example using ForumPages to build a page url. Notice the ForumPages.pmessage. The "pmessage" enumerator constant translates to /forum/pages/pmessage.ascx.

this.Pm.NavigateUrl = YafBuildLink.GetLinkNotEscaped(ForumPages.pmessage, 
   "u={0}", this.PostData.UserId);

Here's an abbreviated ForumPages enumerator class with the additional Sueetie pages. Sueetie pages begin with "su_" with Sueetie pages used in mobile design start with "su_mobile."

Image 

Determining when to load Mobile or Standard Pages

If you've been following Sueetie development for any time at all you know the more simple the logic the better, and with YetAnotherForum.NET's clean hierarchical design we can implement a mobile-vs-standard determination very easily. We go to YAF's Forum.cs base page (in the WebApplication /Classes source directory for quick access), and add one simple test to set the current ForumPages page enum.

We're breaking out the forum home page, topics, posts and post message pages, so upon determining the current ForumPages value we add the following.

ForumPages srcForumPage = this._page;

if (SueetieContext.Current.IsMobile)
{
  switch (srcForumPage)
  {
    case ForumPages.forum:
      srcForumPage = ForumPages.su_mobileforum;
      break;
    case ForumPages.topics:
      srcForumPage = ForumPages.su_mobiletopics;
      break;
    case ForumPages.posts:
      srcForumPage = ForumPages.su_mobileposts;
      break;
    case ForumPages.postmessage:
      srcForumPage = ForumPages.su_mobilepostmessage;
      break;
    default:
      break;
  }
}

We're using a few other SueetieContext.Current.IsMobile tests in the base Forum.cs base page for tasks like hiding the footer, but that's the Sueetie YAF Mobile logic in a nutshell.

Abbreviated Button Text

No theme (I'd like to add, especially any MOBILE theme) is ever finished, and while the buttons on the Sueetie Mobile version of YetAnotherForum.NET can be further reduced in size, they are smaller than their standard display counterparts because we abbreviated the button text. Changing button text is certainly of no interest apart from how it adheres to YAF's Localization architecture.

On the mobile control's .ASCX button display markup I modified the YAF:ThemeButton properties to retrieve new mobile-specific resource strings from the languages/English.xml file in a new SUEETIE "Page" area. Notice TextLocalizedTag="BUTTON_MOBILE_MOVETOPIC" and TextLocalizedPage="SUEETIE"

<YAF:ThemeButton ID="MoveTopic2" runat="server" CssClass="yafcssbigbutton rightItem"
	OnClick="MoveTopic_Click" TextLocalizedTag="BUTTON_MOBILE_MOVETOPIC" 
	TitleLocalizedTag="BUTTON_MOVETOPIC_TT" TextLocalizedPage="SUEETIE" />
Photo of Dave Burke

About the Author, Dave Burke

Dave is the founder of Sueetie and its Head Ice Cream Scooper. Dave has been building online applications since 1994 when he installed his first web server while an Assistant Professor at East Carolina University. He left Academia in 1995 to focus in online development for business where he worked with both publicly and privately held companies. Dave lives in Burlington, Vermont where he has worked out of his home office as a freelance developer and online community consultant since 2000. Reach him at daveburke@dbvt.com. You can visit his website at dbvt.com. You can also follow Dave on Twitter.

Please login to leave a comment. This completely eliminates spam and allows us to focus on building Sueetie.

Powered by BlogEngine.NET 1.6.0.0
Theme by Dave Burke