Search:
Template:WikiForum > Controls > ForumListing

ForumListing

    Table of contents
    No headers
    /*
    This template will display child sub pages as if they were a list of topics in a forum
    
    Parameters:
        None
    
    To Do:
        Accept sub page location as a parameter
        Add a call to datatable to format forum listings with lots of posts
    
    Credits:
        NielW - Layout code and features from http://deki-examples.wik.is/Templates/Basic_Threaded_Discussion_Forum
    */
    //Forum Listing
    let homepath = page.path .. "/Forum Topics";
    var homepage = wiki.getpage(homepath);
    var empty = true;
    if (homepage != nil) {
       let empty = (#homepage.subpages == 0);
    }
    var topics = [];
    if (!empty) {
       foreach (var p in homepage.subpages) {
          var entry = wiki.page(p.path);
          var originator = entry['//*[@id=\'ForumEntryOriginator\']'];
          if (xml.text(originator) == nil) { let originator = web.link(p.author.uri, p.author.name); }
             var lastAuthor = p.author;
             var lastDate = p.date;
             var lastChange = string.contains(p.editsummary, 'page created') ? '(new)' : '(E)';
             if (#p.comments != 0) {
                var lastComment = list.reverse(p.comments)[0];
                if (date.isafter(lastComment.date, p.date)) {
                let lastAuthor = lastComment.author;
                let lastDate = lastComment.date;
                let lastChange = '(C)';
             }
          }
       let lastAuthor = web.link(lastAuthor.uri, lastAuthor.name);
       let lastDate = date.format(lastDate, 's');
       var sticky = (p.tags.sticky != nil ? 'STICKY!' : '');
       let lastDate = (sticky != '' ? 'z' : 'a') .. lastDate;
       let topics ..= [ { page:p, originator:originator, author:lastAuthor, date:lastDate, change:lastChange, sticky:sticky } ];
       }
    let topics = list.sort(topics, 'date', true);
    }
    
    //I can't get datatable to see the XML table
    //datatable{table: "forumlist",options: {"aaSorting":["4","desc"],"sPaginationType":"full_numbers","iDisplayLength":10 } }; 
    <table id="forumlist" cellspacing="0" cellpadding="4" border="1" id="forumlist" class="table">
        <tbody>
            <tr>
                <th valign="top" style="width: 55%; ">"Topic"</th>
                <th valign="top" style="width: 10%; text-align: center; ">"Starter"</th>
                <th valign="top" style="width: 5%; text-align: center; ">"Replies"</th>
                <th valign="top" style="width: 25%; text-align: center; ">"Last Post"</th>
                <th valign="top" style="width: 5%; ">"Views"</th>
            </tr>
    foreach (var t in topics){
    //            <tr class=__count % 2 == 0 ? 'bg1' : 'bg2'>
             <tr class="bg2">
                <td valign="top"><font size="1" style="font-size: 16px; "><strong><font style="font-size: 10px; color: #598527; ">t.sticky</font> web.link(t.page.uri, t.page.title)</strong></font></td>
                <td style="vertical-align: top; text-align: center; ">t.originator;</td>
                var replies=(#t.page.comments>0)?#t.page.comments-1:0;
                <td style="vertical-align: top; text-align: center; ">replies</td>
                var lastchange = date.format(string.substr(t.date,1),'yyyy-M-d H:mm');' '; 
                if (t.change != "(new)") { 
                    let lastchange = lastchange.."by ".. t.author.." ".. t.change;
                }
                <td valign="top" style="text-align: center; "><font style="font-size: 12px; ">date.format(string.substr(t.date,1),'yyyy-M-d H:mm');' '; if (t.change != '(new)') { 'by '; t.author; ' '; }</font></td>
                <td valign="top" style="text-align: center; ">t.page.viewcount</td>
            </tr>
    }
    if (empty){
            <tr>
                <td colspan="5"><font style="font-size: 14px; "><strong>"(no topics yet)"</strong></font></td>
            </tr>
    }
        </tbody>
    </table>
    

    Files (0)

     

    Comments (0)

    You must login to post a comment.