mirror of
https://github.com/flarum/framework.git
synced 2024-11-23 06:01:56 +08:00
Avoid calculations in views
Instead, look up existence of navigation links in the underlying API document.
This commit is contained in:
parent
2979e8bc28
commit
3480a65989
|
@ -1,9 +1,5 @@
|
|||
<?php
|
||||
$discussion = $document->data;
|
||||
$postsCount = count($discussion->relationships->posts->data);
|
||||
?>
|
||||
<div class="container">
|
||||
<h2>{{ $discussion->attributes->title }}</h2>
|
||||
<h2>{{ $document->data->attributes->title }}</h2>
|
||||
|
||||
<div>
|
||||
@foreach ($posts as $post)
|
||||
|
@ -19,11 +15,11 @@ $postsCount = count($discussion->relationships->posts->data);
|
|||
@endforeach
|
||||
</div>
|
||||
|
||||
@if ($page > 1)
|
||||
@if (isset($document->links->prev))
|
||||
<a href="{{ $url(['page' => $page - 1]) }}">« {{ $translator->trans('core.views.discussion.previous_page_button') }}</a>
|
||||
@endif
|
||||
|
||||
@if ($page < $postsCount / 20)
|
||||
@if (isset($document->links->next))
|
||||
<a href="{{ $url(['page' => $page + 1]) }}">{{ $translator->trans('core.views.discussion.next_page_button') }} »</a>
|
||||
@endif
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue
Block a user