A summary of recent posts is probably a must have on the front page of community portals. Currently, there are two ways of realizing this in WebGUI. One way is by using the "Syndicated Content" asset which can display RSS feeds provided by collaboration systems. Another way is by querying the WebGUI database directly using an SQL report. Currently, only the second way is covered by this article.
In order to create your own summary, just follow these instructions:
1. Create an SQL report in the place were you want to have it.
2. Fill in the following SQL query
SELECT ad.title, ad.url, p.username, p.revisionDate, a.createdBy
FROM Post p
JOIN asset a USING (assetId)
JOIN assetData ad USING (assetId, revisionDate)
JOIN Thread t ON p.threadId = t.assetId
JOIN asset ta ON t.assetId = ta.assetId
JOIN asset forum ON ta.parentId = forum.assetId
WHERE forum.parentId = 'HYT3tV2fsm4v4enQuNefbg'
AND ad.groupIdView = '7'
AND a.state = 'published'
AND p.revisionDate = (SELECT MAX(revisionDate) FROM Post WHERE assetId = p.assetId)
AND t.revisionDate = (SELECT MAX(revisionDate) FROM Thread WHERE assetId = t.assetId)
ORDER BY p.revisionDate DESC
LIMIT 8;
It will fetch the last 8 posts from all fores within the message board having id "HYT3tV2fsm4v4enQuNefbg". The query is further restricted to posts that can be viewed by group 7, which is the group id for "Everyone" on my site. If you want more than 8 posts, you may change the number in the LIMIT statement.
3. Create a new template for displaying posts. Usually it is best to copy
the default template and replace the rows_loop by something like
<div class="postSummary">
<tmpl_loop rows_loop>
<p>
<a class="contentLink" href="^/;<tmpl_var row.field.url.value>"><tmpl_var row.field.title.value></a>
<span class="legend">
(von <a href="?op=viewProfile;uid=<tmpl_var row.field.createdBy.value>"><tmpl_var row.field.username.value></a>
am ^D("%d.%m.%Y",<tmpl_var row.field.revisionDate.value>);)
</span>
</p>
</tmpl_loop>
</div>
4. Edit the SQL report asset to use the new style template you created.
Done! Go and play with it...
Tested on WebGUI 7.4.38
Keywords: board, forum, message posts summary,