XF 2.2 /whats-new/resources/

Robert9

Well-known member
I want to remove some rm categories from this page, but i dont want to use the permissions for this.

Is here the right position for this?

FindNew/ResourceItem

Code:
    public function getResultIds(array $filters, $maxResults)
    {
        $visitor = \XF::visitor();

        /** @var \XFRM\Finder\ResourceItem $finder */
        $finder = \XF::finder('XFRM:ResourceItem')
            ->with('Category', true)
            ->with('Category.Permissions|' . $visitor->permission_combination_id)
            ->where('resource_state', '<>', 'deleted')

->where('resource_category_id', '<>', '1')

            ->where('last_update', '>', \XF::$time - (86400 * \XF::options()->readMarkingDataLifetime))
            ->order('last_update', 'DESC');
 
I don't have a XFRM license, but looking at the XFMG code, a better place might be the applyFilters function in the same file.

Try adding something like this via class extension:

PHP:
protected function applyFilters(\XFRM\Finder\ResourceItem $finder, array $filters)
{
    $allowedCategories = [1,2,3];
    $finder->where('resource_category_id', $allowedCategories);

    parent::applyFilters(\XFRM\Finder\ResourceItem $finder, array $filters);
}

You can also work with an admin option to define allowed or disallowed categories, which makes the whole thing more dynamic.
 
Thank you. When i do a query i try to limit the query itself.

But to filter is maybe the right way, when i still have an arrayCollection like here:

 
Top Bottom