Tags:
twiki_application1Add my vote for this tag create new tag
, view all tags

Question

I would like to build a little page that allows users to submit "links of interest" that would then be searchable. There would not be a need to have each link have its own topic. So, it would be like a cross between a comments page and a form-based database. Is this possible?

Environment

TWiki version: TWikiRelease04x01x02
TWiki plugins:  
Server OS:  
Web server:  
Perl version:  
Client OS:  
Web Browser:  
Categories:  

-- SeanDavis - 09 Nov 2007

Answer

ALERT! If you answer a question - or have a question you asked answered by someone - please remember to edit the page and set the status to answered. The status is in a drop-down list below the edit box.

I have created this using CommentPlugin to let users add to a table.

Put this into TWiki.UserCommentsTemplate:

--++ newsbitetable

%TMPL:DEF{PROMPT:newsbitetable}%
%INCLUDE{"TWiki.UserCommentsTemplate" section="tableEntryMakeSafe"}%
<div class="twikiFormSteps">
<div class="twikiFormStep twikiLast">
%TABLE{databg="#F8FBFC" tableborder="0" cellborder="0"}%
|        <label for="comment_url">Url</label>| <input class="twikiInputField" %DISABLED% type="text" size="40" name="comment_url" value="http://" onblur="this.value=makeSafe(this.value)" /> |
|        <label for="comment_title">Title</label>| <input class="twikiInputField" %DISABLED% type="text" size="40" name="comment_title" value="" onblur="this.value=makeSafe(this.value)" /> |
|        <label for="comment_remark">Remarks (optional)</label>| <input class="twikiInputField" %DISABLED% type="text" size="40" name="comment_remark" value="" onblur="this.value=makeSafe(this.value)" /> |
|| <input %DISABLED% type="submit" class="twikiButton" value="%button|Add%" /> |
</div>
</div>
%TMPL:END%

%TMPL:DEF{OUTPUT:newsbitetable}%%POS:AFTER%| %URLPARAM{"comment_url"}% | %URLPARAM{"comment_title" }% | %URLPARAM{"comment_remark" }% | %DATE% |
%TMPL:END%

---++ Javascript tableEntryMakeSafe

%STARTSECTION{"tableEntryMakeSafe"}%
<noautolink>
<script type="text/javascript">
//<![CDATA[
function makeSafe (inText) {
    if (inText.length == 0) return "";
    var re, safeString = inText;

    // replace \n by \r
    re = new RegExp(/\r/g);
    safeString = safeString.replace(re, "\n");

    // remove pipes
    re = new RegExp(/\|/g);
    safeString = safeString.replace(re, "");

    // replace double newlines
    re = new RegExp(/\n\s*\n/g);
    safeString = safeString.replace(re, "%<nop>BR%%<nop>BR%");

    // replace single newlines
    re = new RegExp(/\n/g);
    safeString = safeString.replace(re, "%<nop>BR%");

    return safeString;
}
//]]>
</script>
</noautolink>
%ENDSECTION{"tableEntryMakeSafe"}%

Then in a topic, write:

%COMMENT{type="newsbitetable"}%%STARTINCLUDE%

I have used RenderTableDataPlugin to create a list of the 3 most recent items on our front page.

-- ArthurClemens - 09 Nov 2007

 
Change status to:
Topic revision: r3 - 2007-11-11 - PeterThoeny
 
Twitter Delicious Facebook Digg Google Bookmarks E-mail LinkedIn Reddit StumbleUpon    
  • Download TWiki
TWiki logo Powered by PerlIdeas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2012 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.