How I got MyBB 1.6 to work on a Smartphone
#1
Edit: The patch is too much of a hack to use with anything besides my own forum. People who want to use MyBB on a mobile site should look at MyBB-GoMobile; I have made a copy of the program (70k zipfile) should that website ever go down.

A cursory glance shows that there isn't a formal project undergoing active development getting MyBB to look decent on a smartphone (for example, http://community.mybb.com/thread-76078.html ) (Edit MyBB Go Mobile’s web page is closed, but here’s a GitHub copy of the software: https://github.com/jasonliehr/MyBB-GoMobile )

That in mind, I just went ahead and hacked smartphone support in to MyBB this morning.

What I did requires a working knowledge of HTML and CSS. First of all, I hacked the MyBB source to change the selector for the "global.css" file so that smart phones do not see it:

http://samiam.org/software/MyBB-1.6-smartphone.patch

Once I did that, I then did some template hacking. The goal of the hacks was to:
  • Have an alternate stylesheet visible to mobile users
  • Reduce the clutter on small screens by hiding some fields from smartphone users.
Here is the beginning of my header template:

<link rel="stylesheet" type="text/css" href="/forum_smartphone.css"
      media="only screen and (max-width: 640px)" />
<meta name="viewport" 
content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0"
>

This code tells smartphones to load the alternative forum_smartphone.css file, and to not be small text with pinch zoom enabled.

The forum_smartphone.css file has CSS like this:

.logo { display: none; }

.nomobile { display: none; }

.hidden { display: none; }

.trow_sep {
        background: #e5e5e5;
        color: #000;
        font-size: 10pt;
        font-family: Verdana, "Bitstream Vera Sans", Geneva, "DejaVu Sans", sans-serif;
        font-weight: normal;
}

.menu  {
	display: none;
}

#panel {
        font-family: Verdana, "Bitstream Vera Sans", Geneva, "DejaVu Sans", sans-serif;
        background: #8fc1f2;
        font-size: 10pt;
        padding: 2px;
}

#panel .remember_me input {
        vertical-align: middle;
        margin-top: -1px;
}

Here, we see it hiding some things (like my logo, which is too big for a smart phone, as well as the menu at the top) and providing alternate simplified versions of other elements.

I then modified some templates to not clutter a small smartphone screen with too much information. For example, here is the forumdisplay_subforums template:

<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
<tr>
<td class="thead" colspan="5" align="center"><strong>{$lang->sub_forums_in}</strong></td>
</tr>
<tr>
<td class="tcat" width="2%">&nbsp;</td>
<td class="tcat" width="59%"><span class="smalltext"><strong>{$lang->forumbit_forum}</strong></span></td>
<td class="nomobile tcat" width="7%" align="center" style="white-space: nowrap"><span class="smalltext"><strong>{$lang->forumbit_threads}</strong></span></td>
<td class="nomobile tcat" width="7%" align="center" style="white-space: nowrap"><span class="smalltext"><strong>{$lang->forumbit_posts}</strong></span></td>
<td class="nomobile tcat" width="15%" align="center"><span class="smalltext"><strong>{$lang->forumbit_lastpost}</strong></span></td>
</tr>
{$forums}
</table>
<br />

The important thing to note is the "nomobile" in most table columns; only the forum name is visible on a smartphone screen.

I made similar edits in forumdisplay_threadlist, forumdisplay_threadlist_rating, forumdisplay_thread_rating, forumdisplay_thread, showthread, showthread_quickreply, and possibly some other templates.

The point being: While MyBB was developed before the explosion of smartphones, its templating system is flexible enough to look nice on smartphones once a small patch is applied to the source code to change how the global CSS selector looks.
Reply
#2
Well props for trying to do something in this area. Just depends on the theme you get imo on how well it works on mobile. I have had several themes that worked great on mobile.

Reply
#3
Can you name some good mobile compatible themes? I would like to give them a look.

I'm having issues getting "new thread" or "new reply" to look decent on a smartphone (my current workaround is to have a smartphone thread where they can post quick replies, which are much easier to make small screen compatible).
Reply
#4
Well Gaming Jam from Audentio worked good but it was a premium theme and http://mods.mybb.com/view/alpha-gaming that one worked fairly well for me also.

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)