Browse Source

Optimize catalog.

pull/21/head
Ned Zimmerman 7 years ago
parent
commit
07546254da
No known key found for this signature in database
GPG Key ID: FF56334A013120CA
  1. 4
      app/controllers/App.php
  2. 11
      app/controllers/FrontPage.php
  3. 14
      app/controllers/PageCatalog.php
  4. 6
      resources/views/page-catalog.blade.php
  5. 6
      resources/views/partials/front-page-catalog.blade.php

4
app/controllers/App.php

@ -87,12 +87,12 @@ class App extends Controller
public function currentSubject()
{
return (get_query_var('pb_subject')) ? get_query_var('pb_subject') : '';
return (get_query_var('subject')) ? get_query_var('subject') : '';
}
public function currentLicense()
{
return (get_query_var('pb_license')) ? get_query_var('pb_license') : '';
return (get_query_var('license')) ? get_query_var('license') : '';
}
public function currentOrderBy()

11
app/controllers/FrontPage.php

@ -28,4 +28,15 @@ class FrontPage extends Controller
return __('Our Latest Titles', 'aldine');
}
public function totalPages()
{
return App::totalPages(3);
}
public function books()
{
$page = (get_query_var('paged')) ? get_query_var('paged') : 1;
return App::books($page, 3);
}
}

14
app/controllers/PageCatalog.php

@ -99,4 +99,18 @@ class PageCatalog extends Controller
],
];
}
public function totalPages()
{
return App::totalPages(9);
}
public function books()
{
$page = (get_query_var('paged')) ? get_query_var('paged') : 1;
$orderby = (get_query_var('orderby')) ? get_query_var('orderby') : 'title';
$subject = (get_query_var('subject')) ? get_query_var('subject') : '';
$license = (get_query_var('license')) ? get_query_var('license') : '';
return App::books($page, 9, $orderby, $license, $subject);
}
}

6
resources/views/page-catalog.blade.php

@ -40,15 +40,15 @@
</div>
</div>
<div class="books">
@foreach(App::books($current_page, 9, $current_order_by) as $book)
@foreach($books as $book)
@include('partials.book', ['book' => $book])
@endforeach
</div>
@if(App::totalPages(9) > 1)
@if($total_pages > 1)
<nav class="catalog-navigation">
@if(App::previousPage($current_page))<a class="previous" data-page="{{ App::previousPage($current_page) }}" href="{{ network_home_url('/catalog/page/' . App::previousPage($current_page) . '/') }}">@php(include get_theme_file_path() . '/dist/' . Aldine\svg_path('images/left-arrow.svg')) {{ __('Previous', 'aldine') }}</a>@endif
<div class="pages">
@for($i = 1; $i <= App::totalPages(9); $i++)
@for($i = 1; $i <= $total_pages; $i++)
@if($i === $current_page)
<span class="current">{{ $i }}</span>
@else

6
resources/views/partials/front-page-catalog.blade.php

@ -1,10 +1,8 @@
<div id="latest-titles" class="latest-books w-100">
Page {{ $current_page }}
Total: {{ App::totalPages(3) }}
<h3 class="tc ttu">{{ $latest_books_title }}</h3>
<div class="track flex flex-row flex-wrap justify-center items-center">
<div class="books flex flex-column justify-center items-center order-0 order-1-l flex-row-l justify-between-l" data-total-pages="{{ App::totalPages(3) }}" data-next-page="2">
@foreach(App::books($current_page, 3) as $book)
<div class="books flex flex-column justify-center items-center order-0 order-1-l flex-row-l justify-between-l" data-total-pages="{{ $total_pages }}" data-next-page="2">
@foreach($books as $book)
<div class="book flex flex-column justify-end w-100">
@if(isset($book['metadata']['keywords']))
<p class="subject tc ma0">

Loading…
Cancel
Save