Add staff section on Manga detail pages

This commit is contained in:
Timothy Warren 2018-10-29 15:17:48 -04:00
parent 679c369427
commit bd4cfaafe1
3 changed files with 49 additions and 20 deletions

View File

@ -73,4 +73,39 @@
</section> </section>
<?php endforeach ?> <?php endforeach ?>
<?php endif ?> <?php endif ?>
<?php if (count($staff) > 0): ?>
<br />
<hr />
<h2>Staff</h2>
<?php foreach ($staff as $role => $people): ?>
<h3><?= $role ?></h3>
<section class='media-wrap flex flex-wrap flex-justify-start'>
<?php foreach ($people as $pid => $person): ?>
<article class='character person'>
<?php $link = $url->generate('person', ['id' => $pid]) ?>
<div class="name">
<a href="<?= $link ?>">
<?= $person['name'] ?>
</a>
</div>
<a href="<?= $link ?>">
<picture>
<source
srcset="<?= $urlGenerator->assetUrl("images/people/{$pid}.webp") ?>"
type="image/webp"
>
<source
srcset="<?= $urlGenerator->assetUrl("images/people/{$pid}.jpg") ?>"
type="image/jpeg"
>
<img src="<?= $urlGenerator->assetUrl("images/people/{$pid}.jpg") ?>" alt="" />
</picture>
</a>
</article>
<?php endforeach ?>
</section>
<?php endforeach ?>
<?php endif ?>
</main> </main>

View File

@ -16,8 +16,6 @@
namespace Aviat\AnimeClient\Controller; namespace Aviat\AnimeClient\Controller;
use function Aviat\AnimeClient\getLocalImg;
use Aviat\AnimeClient\Controller as BaseController; use Aviat\AnimeClient\Controller as BaseController;
use Aviat\AnimeClient\API\JsonAPI; use Aviat\AnimeClient\API\JsonAPI;
use Aviat\Ion\ArrayWrapper; use Aviat\Ion\ArrayWrapper;

View File

@ -294,8 +294,6 @@ final class Manga extends Controller {
return; return;
} }
// dd($data['included']);
if (array_key_exists('mediaCharacters', $data['included'])) if (array_key_exists('mediaCharacters', $data['included']))
{ {
$mediaCharacters = $data['included']['mediaCharacters']; $mediaCharacters = $data['included']['mediaCharacters'];
@ -318,27 +316,25 @@ final class Manga extends Controller {
if (array_key_exists('mediaStaff', $data['included'])) if (array_key_exists('mediaStaff', $data['included']))
{ {
foreach ($data['included']['mediaStaff'] as $id => $person) foreach ($data['included']['mediaStaff'] as $id => $staffing)
{ {
$personDetails = []; $role = $staffing['attributes']['role'];
foreach ($person['relationships']['person']['people'] as $p)
foreach($staffing['relationships']['person']['people'] as $personId => $personDetails)
{ {
$personDetails = $p['attributes'];
}
$role = $person['attributes']['role'];
if ( ! array_key_exists($role, $staff)) if ( ! array_key_exists($role, $staff))
{ {
$staff[$role] = []; $staff[$role] = [];
} }
$staff[$role][$id] = [ $staff[$role][$personId] = [
'name' => $personDetails['name'] ?? '??', 'id' => $personId,
'image' => $personDetails['image'], 'name' => $personDetails['attributes']['name'] ?? '??',
'image' => $personDetails['attributes']['image'],
]; ];
} }
} }
}
if ( ! empty($characters['main'])) if ( ! empty($characters['main']))
{ {