FIX: use pagination on comments

This commit is contained in:
Will Rossiter 2012-07-22 13:44:30 +12:00
parent c50740846c
commit 8819fb8381
2 changed files with 15 additions and 12 deletions

View File

@ -62,18 +62,22 @@ class CommentsExtension extends DataExtension {
/**
* Returns a list of all the comments attached to this record.
*
* @todo pagination
*
* @return DataObjectSet
* @return PaginatedList
*/
public function Comments() {
$order = Commenting::get_config_value($this->ownerBaseClass, 'order_comments_by');
return DataObject::get(
'Comment',
"\"ParentID\" = '". $this->owner->ID ."' AND \"BaseClass\" = '". $this->ownerBaseClass ."'",
$order
);
$list = new PaginatedList(Comment::get()->where(sprintf(
"ParentID = '%s' AND BaseClass = '%s'", $this->owner->ID, $this->ownerBaseClass
))->sort($order));
$list->setPageLength(Commenting::get_config_value(
$this->ownerBaseClass, 'comments_per_page'
));
$list->setPaginationGetVar("commentsstart". $this->owner->ID);
return $list;
}
@ -84,7 +88,7 @@ class CommentsExtension extends DataExtension {
* To customize the html see templates/CommentInterface.ss or extend this function with
* your own extension.
*
* @todo Cleanup the passing of all this state based functionality
* @todo Cleanup the passing of all this configuration based functionality
*
* @see docs/en/Extending
*/

View File

@ -1,6 +1,5 @@
<% if CommentsEnabled %>
<div id="$CommentHolderID" class="comments-holder-container">
<h4><% _t('POSTCOM','Post your comment') %></h4>
<% if AddCommentForm %>
@ -20,11 +19,11 @@
<div class="comments-holder">
<% if Comments %>
<ul class="comments-list">
<% control Comments %>
<% loop Comments %>
<li class="comment $EvenOdd<% if FirstLast %> $FirstLast <% end_if %> $SpamClass">
<% include CommentsInterface_singlecomment %>
</li>
<% end_control %>
<% end_loop %>
</ul>
<% if Comments.MoreThanOnePage %>