[decided]Comments Pagination
  • How to make comments pagination for articles?
    Post edited by Andrei S. at 2015-02-19 01:56:20
  • 2 Comments sorted by
  •     {{list_article_comments length="5" order="bydate desc"}}
        {{ if $gimme->current_list->at_beginning }}
        <div class="row comment-box" id="comment-{{$gimme->current_list->index}}">
            <div class="span1">
                {{ if $gimme->comment->user->identifier }}
                <a href="http://{{ $gimme->publication->site }}/user/profile/{{ $gimme->comment->user->uname|urlencode }}" class="avatar">
                    <img src="{{ include file='_tpl/user-image.tpl' user=$user width=60 height=60 }}" alt="{{ $gimme->comment->user->uname }}">
                </a>
                {{ else }}
                    <img src="{{ include file='_tpl/user-image.tpl' user=$user width=60 height=60 }}" alt="{{ $gimme->comment->user->uname }}">
                {{ /if }}
            </div>
            <div class="span7 comment-content">                                               
                <h4 class="pull-left comment-author link-color">
                {{ if $gimme->comment->user->identifier }}
                    <a href="http://{{ $gimme->publication->site }}/user/profile/{{ $gimme->comment->user->uname|urlencode }}">{{ $gimme->comment->user->uname }}</a>
                {{ else }}
                    {{ $gimme->comment->nickname }} ({{ #anonymous# }})
                {{ /if }}
                </h4>
                <div class="pull-right comment-date">
                    <time class="timeago" datetime="{{ $gimme->comment->submit_date }}">{{ $gimme->comment->submit_date }}</time>
                </div>
                <div class="clearfix"></div>
                <div class="comment-body">
                 {{ $gimme->comment->content}}
                </div>                                               
            </div>
        </div>
        {{ else }}
       
        <div class="row comment-box" id="comment-{{$gimme->current_list->index}}">
            <div class="span1">
                {{ if $gimme->comment->user->identifier }}
                <a href="http://{{ $gimme->publication->site }}/user/profile/{{ $gimme->comment->user->uname|urlencode }}" class="avatar">
                    <img src="{{ include file='_tpl/user-image.tpl' user=$user width=60 height=60 }}" alt="{{ $gimme->comment->user->uname }}">
                </a>
                {{ else }}
                    <img src="{{ include file='_tpl/user-image.tpl' user=$user width=60 height=60 }}" alt="{{ $gimme->comment->user->uname }}">
                {{ /if }}
            </div>
            <div class="span7 comment-content">                                               
                <h4 class="pull-left comment-author link-color">
                {{ if $gimme->comment->user->identifier }}
                    <a href="http://{{ $gimme->publication->site }}/user/profile/{{ $gimme->comment->user->uname|urlencode }}">{{ $gimme->comment->user->uname }}</a>
                {{ else }}
                    {{ $gimme->comment->nickname }} ({{ #anonymous# }})
                {{ /if }}
                </h4>
                <div class="pull-right comment-date">
                    <time class="timeago" datetime="{{ $gimme->comment->submit_date }}">{{ $gimme->comment->submit_date }}</time>
                </div>
                <div class="clearfix"></div>
                <div class="comment-body">
                 {{ $gimme->comment->content}}
                </div>                                               
            </div>
        </div>
       
        {{ /if }}
       
        {{ if $gimme->current_list->at_end }}
        {{* PAGINATION *}}
            {{ $pages=ceil($gimme->current_list->count/5) }}
            {{ $curpage=intval($gimme->url->get_parameter($gimme->current_list_id())) }}
            {{ if $pages gt 1 }}
            <nav class="span8">
                <div class="pagination">
                    <ul>
                        {{ if $gimme->current_list->has_previous_elements }}<li class="prev"><a href="{{ uripath options="comment" }}?{{ urlparameters options="previous_items" }}">&laquo;</a></li>{{ /if }}
                        {{ for $i=0 to $pages - 1 }}
                            {{ $curlistid=$i*5 }}
                            {{ $gimme->url->set_parameter($gimme->current_list_id(),$curlistid) }}
                            {{ if $curlistid != $curpage }}
                        <li><a href="{{ uripath options="comment" }}?{{ urlparameters }}">{{ $i+1 }}</a></li>
                            {{ else }}
                        <li class="active disable"><a href="{{ uripath options="comment" }}?{{ urlparameters }}">{{ $i+1 }}</a></li>
                            {{ $remi=$i+1 }}
                            {{ /if }}
                        {{ /for }}
                        {{ if $gimme->current_list->has_next_elements }}<li class="next"><a href="{{ uripath options="comment" }}?{{ urlparameters options="next_items" }}">&raquo;</a></li>{{ /if }}
                    </ul>
                </div>
            </nav>
            {{ $gimme->url->set_parameter($gimme->current_list_id(),$curpage) }}
            {{ /if }}
            {{ /if }}
        {{/list_article_comments}}
    Post edited by Andrei S. at 2015-02-19 01:50:42
  • del
    Post edited by Andrei S. at 2015-02-19 01:50:53