View Full Version : How to simulate a forum/discussion board in DekiWiki
craigsivils
08-28-2008, 04:55 AM
I finally have a decent simulation of a discussion board inside dekiwiki.
The code and a working example can be found at http://wiki.developer.mindtouch.com/User:Craigsivils/How_to_simulate_a_simple_forum
Many thanks to Gianluca and SteveB for the outstanding dekiscript examples.
SteveB
08-29-2008, 03:37 AM
That's freaking brilliant!!! Please move it under MindTouch_Deki/DekiScript/FAQ where all the samples are located.
Really, very nice. I'm impressed!
owensleftfoot
08-29-2008, 10:26 AM
I must be doing something wrong. I get
<tr foreach="var p in subpages" class="reference to undefined name '__count'">
<td valign="top">reference to undefined name 'p'</td>
<td valign="top">reference to undefined name 'authors'</td>
<td valign="top">reference to undefined name 'p'</td>
<td valign="top">reference to undefined name 'p'</td>
<td valign="top">reference to undefined name 'p'</td>
craigsivils
08-29-2008, 03:37 PM
Check the version of the wiki and that you pasted the entire script. I have setup forums on 3 different wiki's that I work with by pasting that script.
neilw
08-29-2008, 09:32 PM
Very nice indeed. We've been doing a lot of stuff here lately based on similar concepts, but this is a neat twist, particularly the code to sort based on most recent reply.
At the risk of needlessly poking my nose in, I offer a modified version:
1) Refactored the code to make fewer redundant function calls. I can only speculate whether this would put marginally less load on the server and perhaps render pages faster, but I find it cleaner and easier to read if nothing else. I perform some of the operations quite differently, some may find it instructive.
2) Added code to display the originator of the topic, in addition to the most recent commenter.
3) Reformatted the output a bit to look more like this forum (and more forum-like as a whole.)
See it here (http://wiki.developer.mindtouch.com/User:Neilw/Forum_simulator).
hannan54
08-30-2008, 02:58 AM
Not to be a total noob, but how exactly do you add this function to a page? Do you just add it to the custom html section in the visual appearances page?
Also, will it be then added to every page or can you control which pages have that feature?
I'd really like to start using this option, it's pretty nice!
craigsivil's example can be pasted from the "HTML source" mode when you edit a page - the page you edit should be a parent page of your "forum post" deki pages.
craigsivils
08-30-2008, 01:43 PM
Very nice indeed. We've been doing a lot of stuff here lately based on similar concepts, but this is a neat twist, particularly the code to sort based on most recent reply.
At the risk of needlessly poking my nose in, I offer a modified version:
1) Refactored the code to make fewer redundant function calls. I can only speculate whether this would put marginally less load on the server and perhaps render pages faster, but I find it cleaner and easier to read if nothing else. I perform some of the operations quite differently, some may find it instructive.
2) Added code to display the originator of the topic, in addition to the most recent commenter.
3) Reformatted the output a bit to look more like this forum (and more forum-like as a whole.)
See it here (http://wiki.developer.mindtouch.com/User:Neilw/Forum_simulator).
Thank you!
I couldn't find an example of a list of maps, and my few attempts on my own did not go well.
I love the changes you made, my only comment is that I think you still need one more if statement to check if the edit date is greater than the last comment date. This is to cover the situation where the original post was edited.
Please feel free to overwrite the code in the FAQ section. I want the best code to be there as an example, and yours is good enough I plan to replace my forum code inside my own wiki's.
Craig
craigsivils
08-30-2008, 02:25 PM
I added the extra if statement, corrected a date formatting error that was in my original code (used m for minute rather than mm) and moved the code to http://wiki.developer.mindtouch.com/MindTouch_Deki/DekiScript/FAQ/Simulate_a_discussion_board
It is community code, so please feel free to improve as needed.
Powered by vBulletin™ Version 4.1.3 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.