Category:Forums
Category:Templates
Category:Mobile
See this Forum Thread for the original discussion.
We had a user request a WAP version of our forums, so guess how I spent my Sunday afternoon?
I got it working and thought I’d share, in case anyone else ever feels compelled to approach it.
It uses the templating system not the forum templates. I don’t know how to parse the pmcode properly, but your WAP users will probably appreciate it, even if it isn’t as pretty as it could be.
You can see it working here.
It is composed of three templates:
This first one uses the Recently posted as the launching point (Index page):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{lang}" lang="{lang}">
<head>
<title>WAP Forum - The Other Side of Kim du Toit</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel='stylesheet' type='text/css' media='all' href='{stylesheet=tos-shared/tos}' />
<style type='text/css' media='screen'>@import "{stylesheet=tos-shared/tos}";</style>
</head>
<body>
<h2>50 Recently Discussed</h2>
<div id=wrappost>
<font size="1">
<table width="100%" border="1" cellspacing="0" cellpadding="6">
<tr>
<td width="30%">Title</td>
<td width="15%">Author</td>
<td width="15%">Posted On</td>
<td width="5%">Posts</td>
<td width="5%">Views</td>
<td width="30%">Last Post Info</td>
</tr>
{exp:forum:topic_titles orderby="recent_post" sort="desc" limit="50"}
<tr>
<td valign="top"><a href="{path=wapforum/topic/}{topic_id}">{title}</a></td>
<td valign="top"><a href="{profile_path=forums/member}">{author}</a></td>
<td valign="top">{topic_date format="%m/%d/%Y %h:%i %a"}</td>
<td valign="top">{post_total}</td>
<td valign="top">{views}</td>
<td valign="top">On: {last_post_date format="%m/%d/%Y %h:%i %a"} |
By: <a href="{last_author_profile_path=forums/member}">{last_author}</a>
</tr>
{/exp:forum:topic_titles}
</table>
</font>
</div>
</body>
</html>
The second template displays the forum topic and includes an embed of the posts to that topic (template name: topic):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{lang}" lang="{lang}">
<head>
<title>WAP Forum - The Other Side of Kim du Toit</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel='stylesheet' type='text/css' media='all' href='{stylesheet=tos-shared/tos}' />
<style type='text/css' media='screen'>@import "{stylesheet=tos-shared/tos}";</style>
</head>
<body>
<div id=wrappost>
{exp:query sql="SELECT t.topic_id AS topic_id, t.author_id AS topic_author_id, t.title AS title, FROM_UNIXTIME(t.topic_date,'%m/%d/%Y %h:%i %A') AS topic_date, FROM_UNIXTIME(t.last_post_date,'%m/%d/%Y') AS last_topic_date, t.thread_total, t.thread_views, t.body AS topic_body, f.forum_status, f.forum_permissions, m.screen_name AS author
FROM exp_forum_topics t, exp_forums f, exp_members m
WHERE t.forum_id = f.forum_id
AND t.author_id = m.member_id
AND t.topic_id = {segment_3}
"}
<h1>{title}</h1>
<b>Author:</b> {author}<br />
<b>Date:</b> {topic_date}<br />
<p>{topic_body}</p>
{/exp:query}
{embed=wapforum/comments}
</div>
</body>
</html>
The third page is embedded in the above so be sure to rename the embed to whatever you are calling this one (template name: comments):
<br />
<b>Responses:</b><br /><br />
<table border="1" cellspacing="0" cellpadding="4">
<tr>
<td><center><font size="1">Author</font></center></td>
<td><center><font size="1">Date Posted</font></center></td>
<td><center><font size="1">Comment</font></center></td>
</tr>
{exp:query sql="SELECT c.author_id AS comment_author_id, FROM_UNIXTIME(c.post_date,'%m/%d/%Y %h:%i %A') AS comment_date, c.body AS comment_body, m.screen_name AS comment_author
FROM exp_forum_posts c, exp_members m
WHERE c.author_id = m.member_id
AND c.topic_id = {segment_3}
ORDER BY comment_date ASC
"}
<tr>
<td valign="top">{comment_author}</td>
<td valign="top">{comment_date}</td>
<td valign="top"><p>{comment_body}</p></td>
</tr>
{/exp:query}
</table>
I created a template group “wapforum” but you can do it anyway you want. You’ll need to adjust the embeds and links based on how you name things.
