mirror of
https://github.com/flarum/framework.git
synced 2025-03-02 13:17:55 +08:00
Avoid calculations in views
Instead, look up existence of navigation links in the underlying API document.
This commit is contained in:
parent
81c86b726c
commit
b491bd1e36
@ -1,9 +1,5 @@
|
|||||||
<?php
|
|
||||||
$discussion = $document->data;
|
|
||||||
$postsCount = count($discussion->relationships->posts->data);
|
|
||||||
?>
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<h2>{{ $discussion->attributes->title }}</h2>
|
<h2>{{ $document->data->attributes->title }}</h2>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
@foreach ($posts as $post)
|
@foreach ($posts as $post)
|
||||||
@ -19,11 +15,11 @@ $postsCount = count($discussion->relationships->posts->data);
|
|||||||
@endforeach
|
@endforeach
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@if ($page > 1)
|
@if (isset($document->links->prev))
|
||||||
<a href="{{ $url(['page' => $page - 1]) }}">« {{ $translator->trans('core.views.discussion.previous_page_button') }}</a>
|
<a href="{{ $url(['page' => $page - 1]) }}">« {{ $translator->trans('core.views.discussion.previous_page_button') }}</a>
|
||||||
@endif
|
@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>
|
<a href="{{ $url(['page' => $page + 1]) }}">{{ $translator->trans('core.views.discussion.next_page_button') }} »</a>
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user