Browse Source

Fix catalog subjects issue

pull/135/head
Ned Zimmerman 6 years ago
parent
commit
e7e4b51063
  1. 5
      inc/helpers/namespace.php
  2. 7
      partials/book.php

5
inc/helpers/namespace.php

@ -7,8 +7,9 @@
namespace Aldine\Helpers; namespace Aldine\Helpers;
use Pressbooks\Book;
use function \Pressbooks\Metadata\book_information_to_schema; use function \Pressbooks\Metadata\book_information_to_schema;
use function \Pressbooks\Metadata\is_bisac;
use Pressbooks\Book;
/** /**
* @param int $page * @param int $page
@ -142,7 +143,7 @@ function get_available_licenses( $catalog_data ) {
function get_available_subjects( $catalog_data ) { function get_available_subjects( $catalog_data ) {
$subjects = []; $subjects = [];
foreach ( $catalog_data['books'] as $book ) { foreach ( $catalog_data['books'] as $book ) {
if ( ! empty( $book['subject'] ) ) { if ( ! empty( $book['subject'] ) && ! is_bisac( $book['subject'] ) ) {
$subjects[ substr( $book['subject'], 0, 1 ) ][] = substr( $book['subject'], 0, 2 ); $subjects[ substr( $book['subject'], 0, 1 ) ][] = substr( $book['subject'], 0, 2 );
} }
} }

7
partials/book.php

@ -1,6 +1,9 @@
<?php use function \Aldine\Helpers\maybe_truncate_string; ?> <?php
use function \Aldine\Helpers\maybe_truncate_string;
use function \Pressbooks\Metadata\is_bisac;
?>
<?php $subject = ( isset( $book['subject'] ) ) ? substr( $book['subject'], 0, 2 ) : ''; <?php $subject = ( isset( $book['subject'] ) && ! is_bisac( $book['subject'] ) ) ? substr( $book['subject'], 0, 2 ) : '';
$date = ( isset( $book['metadata']['datePublished'] ) ) ? str_replace( '-', '', $book['metadata']['datePublished'] ) : ''; $date = ( isset( $book['metadata']['datePublished'] ) ) ? str_replace( '-', '', $book['metadata']['datePublished'] ) : '';
?> ?>
<li class="book" <li class="book"

Loading…
Cancel
Save