forked from Public/pics
AlbumButtonBox: add way for users to select an album filter
This commit is contained in:
@@ -8,11 +8,15 @@
|
||||
|
||||
class AlbumButtonBox extends Template
|
||||
{
|
||||
private $active_filter;
|
||||
private $buttons;
|
||||
private $filters;
|
||||
|
||||
public function __construct($buttons)
|
||||
public function __construct(array $buttons, array $filters, $active_filter)
|
||||
{
|
||||
$this->active_filter = $active_filter;
|
||||
$this->buttons = $buttons;
|
||||
$this->filters = $filters;
|
||||
}
|
||||
|
||||
public function html_main()
|
||||
@@ -25,6 +29,25 @@ class AlbumButtonBox extends Template
|
||||
<a class="btn btn-light" href="', $button['url'], '">', $button['caption'], '</a>';
|
||||
|
||||
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 '
|
||||
<li><a class="dropdown-item', $is_active ? ' active' : '',
|
||||
'" href="', $filter['link'], '">',
|
||||
$filter['caption'],
|
||||
'</a></li>';
|
||||
}
|
||||
|
||||
echo '
|
||||
</ul>
|
||||
</div>
|
||||
</div>';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user