Allow users to filter albums by contributors #48
@ -47,15 +47,19 @@ class ViewPhotoAlbum extends HTMLController
|
||||
$contributors = $tag->getContributorList();
|
||||
|
||||
// Enumerate possible filters
|
||||
$filters = ['' => ['id_user' => null, 'caption' => 'Show all photos', 'link' => $tag->getUrl()]];
|
||||
foreach ($contributors as $contributor)
|
||||
$filters = [];
|
||||
if (!empty($contributors))
|
||||
{
|
||||
$filters[$contributor['slug']] = [
|
||||
'id_user' => $contributor['id_user'],
|
||||
'caption' => sprintf('By %s (%s photos)',
|
||||
$contributor['first_name'], $contributor['num_assets']),
|
||||
'link' => $tag->getUrl() . '/?by=' . $contributor['slug'],
|
||||
];
|
||||
$filters[''] = ['id_user' => null, 'caption' => 'Show all photos', 'link' => $tag->getUrl()];
|
||||
Aaron marked this conversation as resolved
Outdated
|
||||
foreach ($contributors as $contributor)
|
||||
{
|
||||
$filters[$contributor['slug']] = [
|
||||
'id_user' => $contributor['id_user'],
|
||||
'caption' => sprintf('By %s (%s photos)',
|
||||
$contributor['first_name'], $contributor['num_assets']),
|
||||
'link' => $tag->getUrl() . '/?by=' . $contributor['slug'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// Limit to a particular uploader?
|
||||
|
@ -28,26 +28,31 @@ class AlbumButtonBox extends Template
|
||||
echo '
|
||||
<a class="btn btn-light" href="', $button['url'], '">', $button['caption'], '</a>';
|
||||
|
||||
echo '
|
||||
if (!empty($this->filters))
|
||||
{
|
||||
echo '
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-light dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<i class="bi bi-filter"></i>
|
||||
</button>
|
||||
<ul class="dropdown-menu">';
|
||||
|
||||
foreach ($this->filters as $key => $filter)
|
||||
{
|
||||
$is_active = $key === $this->active_filter;
|
||||
echo '
|
||||
foreach ($this->filters as $key => $filter)
|
||||
{
|
||||
$is_active = $key === $this->active_filter;
|
||||
echo '
|
||||
<li><a class="dropdown-item', $is_active ? ' active' : '',
|
||||
'" href="', $filter['link'], '">',
|
||||
$filter['caption'],
|
||||
'</a></li>';
|
||||
}
|
||||
|
||||
echo '
|
||||
</ul>
|
||||
</div>';
|
||||
}
|
||||
|
||||
echo '
|
||||
</ul>
|
||||
</div>
|
||||
</div>';
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user
Key
label
missingI initially didn't add it as it'd never be used. You're right, though, and it's better to just have it there for consistency.