Comments module:
The comments module is used on this website pages to add contributions from visitors at the bottom of a page. You will find below the structure of the 'Comment' object to reproduce so that the content row can create the display for the site. Of course, this code is given as an example and can be modified according to your needs.
Structure of the 'Comment' object:
Here are the different fields (and their types) that compose a 'Comment' object:
- Author (Character chain)
- Email (Character chain)
- Website (Character chain)
- Comment (Text field)
- Date of creation (Date)
- Page (Page)
- Email notification (Email notification)
Content row:
Here is the XML code which creates the row displays and allows comments on a page. It is the code used for the "Add a contribution" that we find at the bottom of all the pages of the manual, including this one.
This row first effects a search of comments for the current page and next displays the results.
In addition, it allows one to write a comment by displaying a comment box.
<row>
<block module="comments" id="comment" language="fr">
<div id="comments">
<atm-if what="!{request:int:viewComments}">
<h2>
<atm-search what="{Comment}" name="searchComment">
<atm-search-param search="searchComment" type="{Comment:Page:fieldID}" value="{page:self:id}" mandatory="true" />
<atm-search-limit search="searchComment" value="1" />
<atm-search-page search="searchComment" value="1" />
<atm-result search="searchComment">
<a href="{page:self:url}?viewComments=1#viewComments" title="{maxresults} comment(s)">{maxresults} comment(s)</a>
</atm-result>
<atm-noresult search="searchComment"><a href="{page:self:url}?viewComments=1#addComment">Add a contribution</a></atm-noresult>
</atm-search>
</h2>
</atm-if>
<atm-if what="{request:int:viewComments}">
<atm-search what="{Comment}" name="searchComment">
<atm-search-param search="searchComment" type="{Commentaire:Page:fieldID}" value="{page:self:id}" mandatory="true" />
<atm-search-order search="searchComment" type="objectID" direction="asc" />
<atm-result search="searchComment">
<atm-if what="{firstresult}">
<a name="viewComments"> </a>
<h2>Comments : </h2>
</atm-if>
<div class="comment">
<a name="comment{Comment:id}"> </a>
<h3>Par
<atm-if what="{Comment:Site_web:value}">
<?php
$website = {Comment:Site_web:value};
if (substr($website, 0, 4) !== 'http') {
$website = 'http://'.$website;
}
?>
<a href="{var:string:website}" target="_blank" rel="nofollow">{Comment:Author:value}</a>
</atm-if>
<atm-if what="!{Commentaire:Site_web:value}">
{Comment:Author:value}
</atm-if>
le {Comment:Date_of_creation:formatedValue|d/m/Y H:i:s} :</h3>
{Comment:Comment:htmlvalue}<br />
</div>
</atm-result>
</atm-search>
<a name="addComment"> </a>
<h2>Add your contribution : </h2>
<div class="comment">
<atm-form what="{Comment}" name="addComment">
<atm-if what="{filled}">
<div class="comment-ok">Comment successfully added !</div>
</atm-if>
<atm-if what="!{filled}">
<atm-if what="{required}">
<span class="comment-alert">
<ul>
<atm-form-required form="addComment">
<li>{requiredname} field is required ...</li>
</atm-form-required>
</ul>
</span>
</atm-if>
<atm-if what="{malformed}">
<span class="comment-alert">
<ul>
<atm-form-malformed form="addComment">
<li>{malformedname} field is incorrect...</li>
</atm-form-malformed>
</ul>
</span>
</atm-if>
<input type="hidden" value="1" name="viewComments"/>
<label for="12_0"><span class="comment-alert">*</span> Name :</label><br />
<atm-input field="{Comment:Author}" form="addComment" /><br />
<label for="15_0"><span class="comment-alert">*</span> Email <small>(Invisible on the site)</small> :</label><br />
<atm-input field="{Comment:Email}" form="addComment" /><br />
<label for="18_0">Website : </label><br />
<atm-input field="{Comment:Website}" form="addComment" /><br />
<input type="hidden" value="{page:self:id}" name="16_0"/>
<input type="hidden" value="16" name="polymodFields[16]"/>
<input type="hidden" value="1" name="17_0"/>
<input type="hidden" value="17" name="polymodFields[17]"/>
<label for="13_0"><span class="comment-alert">*</span> Text <small>(HTML is not authorized)</small> : </label><br />
<atm-input field="{Comment:Comment}" form="addComment" /><br />
<small>Date de votre contribution : <atm-input field="{Comment:Date_of_creation}" form="addComment" /></small>
<input class="submit" type="submit" name="submit" value="Post your comment" />
<div class="spacer"></div>
</atm-if>
</atm-form>
</div>
</atm-if>
</div>
</block>
</row>
Add a contribution