mattrogowski
Well-known member
In
This is fine if you have forum type-specific filters, but it makes it difficult to create new filters for all forum types that are also available to the forum type handlers, if for any reason you want to check if a filter has been set. It's obviously not possible to extend the abstract forum type handler to apply a filter to all forum types, so the only way to do it is to extend
What I am currently having to do is add a new filter by extending the controller method, but then also check for the same filters again in the forum type handlers, because I need to check if it's been set but to do that I need to re-filter the input instead of just checking if it is set in
All that needs to be done is before this:
add:
and then have a function that does the same as
Then I can define my new global filter here, and it will be available in the forum type filter function so I can check if it has been set.
Hopefully this can be slipped in to 2.3 because the above is all that should need to be added.
XF\Pub\Controller\Forum::getForumFilterInput
it calls $filters = $forum->TypeHandler->getForumFilterInput($forum, $this->request, $filters);
before returning the filters.This is fine if you have forum type-specific filters, but it makes it difficult to create new filters for all forum types that are also available to the forum type handlers, if for any reason you want to check if a filter has been set. It's obviously not possible to extend the abstract forum type handler to apply a filter to all forum types, so the only way to do it is to extend
getForumFilterInput()
, but as I'd have to call the parent function first, $forum->TypeHandler->getForumFilterInput()
has already run, but it won't know anything about my custom filters as I haven't defined them yet.What I am currently having to do is add a new filter by extending the controller method, but then also check for the same filters again in the forum type handlers, because I need to check if it's been set but to do that I need to re-filter the input instead of just checking if it is set in
$filters
. This shouldn't be necessary.All that needs to be done is before this:
PHP:
$filters = $forum->TypeHandler->getForumFilterInput($forum, $this->request, $filters);
add:
PHP:
$filters = $this->getAdditionalFilterInput($forum, $this->request, $filters);
and then have a function that does the same as
XF\ForumType\AbstractHandler::getForumFilterInput
does - just returns the filters unless it's extended:
PHP:
public function getAdditionalFilterInput(Forum $forum, Request $request, array $filters): array
{
return $filters;
}
Then I can define my new global filter here, and it will be available in the forum type filter function so I can check if it has been set.
Hopefully this can be slipped in to 2.3 because the above is all that should need to be added.
Upvote
5