This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

lucas.sanner54070
lucas.sanner54070

In my record list let's say I want to modify the query according to the values picked in the Category filter.
How can I get the current selected values of a given filter from my controller's functions ?

mjauvin
mjauvin
mjauvin

I also suggest looking at popular plugins that use filters to see how it's coded.

lucas.sanner54070
lucas.sanner54070

Thanks. I finally found out the function I need in this post.

function getCurrentFilters() {
    $filters = [];
    foreach (\Session::get('widget', []) as $name => $item) {
        if (str_contains($name, 'Filter')) {
            $filter = @unserialize(@base64_decode($item));
            if ($filter) {
                array_push($filters, $filter);
            }
        }
    }

    return $filters;
}

It's a homemade function but it seems to do the job properly.
However, is there any way to get to the same result natively in October ?

mjauvin
mjauvin

Either I don't understand what you really want to do, or you didn't read this link I sent:

https://octobercms.com/docs/backend/lists#list-filters

lucas.sanner54070
lucas.sanner54070

I did read the documentation but the thing is I want to get the current filter values (scopes) from the reorderExtendQuery($query) function, but unfortunately the $scope parameter is not available here.

mjauvin
mjauvin

Oh, so you want to reorder records of a specific category?

Last updated

lucas.sanner54070

1-8 of 8

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.