wiki:snippets/Template/Guestbook_integration

Guestbook integration

If you want someone to comment your documents, you can easily add a guestbook to them:

<corinis-include type="module" xsl="docment_comment.xsl" name="Guestbook">
   <FUNCTION>getEntry</FUNCTION>
   <moduleName>COMMENT</moduleName>
   <mainId>$Document_id</mainId>
</corinis-include>

where document_comment is something like:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:template match="/">

    <form method="post" action="/addcomment.jsp">
        Benutzername: <input name="Guestbook_name"/><br/>
        Nachricht: <textarea name="Guestbook_message"><xsl:text> </xsl:text></textarea><br/>
        <input name="Guestbook_mainId" type="hidden" value="{/GUESTBOOK/MAINID}"/>
        <input type="hidden" value="COMMENT" name="Guestbook_module"/>
        <input name="Guestbook_createEntry" type="submit"/>
    </form>
    <xsl:for-each select="/GUESTBOOK/ENTRY">
        <xsl:sort select="CREATE/LDATE" order="descending"/>
         <h2>
                <xsl:value-of select="CREATE/USER/NAME"/>:</h2>
         <h3><xsl:value-of select="CREATE/DATE"/></h3>
         <div class="message"> <xsl:value-of select="MESSAGE"/></div>
    </xsl:for-each>

  </xsl:template>

</xsl:stylesheet>

and the addcomment.jsp for writing the content is:

<%@ page language="java" import="java.io.*,corinis.util.*,java.sql.*,java.util.*,corinis.*,corinis.modules.*,corinis.util.*" %>
<%
Core core = new Core(pageContext);
// init modules:
Guestbook gb = (Guestbook)core.getModule(Guestbook.class);
gb.guestbookView.moduleName = "COMMENT";
gb.createEntry();
response.sendRedirect(request.getHeader("Referer"));
return;
%>