The following code simulates a simple forum inside a wiki. Use the "Add Comment" (at the bottom of the page) to reply.
<p>{{wiki.create("Create New Topic",page.path,_,true,"Put Your Title Here")}}</p>
<table cellspacing="0" cellpadding="4" border="1" block="var topics = [];
foreach (var p in page.subpages) {
var originator = wiki.getuser(web.list(p.api .. '/revisions?revision=1', '/page/user.author/username')[0]);
var lastAuthor = originator;
var lastDate = date.format(p.date, 's');
if (#p.comments != 0) {
var lastComment = list.reverse(p.comments)[0];
if (date.isafter(lastComment.date,p.date)){
let lastAuthor = lastComment.author;
let lastDate =date.format(lastComment.date, 's');
}
}
let topics ..= [ { page:p, originator:originator, lastAuthor:lastAuthor, lastDate:lastDate } ];
}
let topics = list.sort(topics, 'lastDate', true);" class="table">
<tbody>
<tr>
<th valign="top" style="width: 70%;">Topic/Starter</th>
<th valign="top" style="width: 15%;">Last Post</th>
<th valign="top" style="width: 7%;">#Views</th>
<th valign="top" style="width: 7%;">#Replies</th>
</tr>
<tr foreach="var t in topics" class="{{__count % 2 == 0 ? 'bg1' : 'bg2'}}">
<td valign="top"><font style="font-size: 17px;"><strong>{{web.link(t.page.uri, t.page.title)}}</strong></font> <br />
{{web.link(t.originator.uri, t.originator.name); }}</td>
<td valign="top">{{date.format(t.lastDate,'yyyy-MM-d hh:mm');}} <br />
by {{web.link(t.lastAuthor.uri, t.lastAuthor.name)}}</td>
<td valign="top">{{t.page.viewcount}}</td>
<td valign="top">{{#t.page.comments}}</td>
</tr>
</tbody>
</table>
| Images 0 | ||
|---|---|---|
| No images to display in the gallery. |
Copyright © 2011 MindTouch, Inc. Powered by
{{ web.link(page.path.."/"..date.month(date.now).."-"..date.day(date.now).."-"..date.year(date.now).." - Replace this text with post title","New Post") }}.
Creates this:
03-20-2008 - Replace this text with post title
Function 'web.link' failed with response:missing value for parameter 'uri' (index 0) at the place where person who posted the subject...
Really don't know what went wrong, I'm not that good with programming languages.
Hope somebody can help me. edited 05:43, 23 Sep 2008
Function 'web.link' failed with response: missing value for parameter 'uri' (index 0)
Any help would be most appreciated.
>Function 'web.link' failed with response: missing value for parameter 'uri' (index 0)
>Any help would be most appreciated.
Me Too!!
Update:
I had implemented as follows
1. A top level page with a title Discussions
This contained a message that access to discussions was for registered users
I have a group called registered
access to lower level pages was restricted to members of that group
2. Below this a few pages each with a discussion forum
Removing the restriction didn't solve the problem because the security remained defaulted to private.
Changing the page back to a public page and all pages below it... worked.
Great but... I would like to be able to have discussions not be public. This was quick and easy and would have been good if it had worked. However, what is really scary is seing a message go unanswered here for a month. I'm a student trying to use this for a project!
edited 09:46, 29 Oct 2008