Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce method to remove the query-string from search-request #4136

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rr-it
Copy link
Contributor

@rr-it rr-it commented Aug 19, 2024

What this PR does

This introduce a new method that removes the query-string from SearchRequest. Other active filters e.g. selected categories are not removed from SearchRequest.

This is especially usefull when allowEmptyQuery is set in TS-config:

plugin.tx_solr {
  search {
    query {
      allowEmptyQuery = 1
    }
}

How to test

This can be used in a custom ViewHelper:

class RemoveQueryViewHelper extends AbstractUriViewHelper
{

    /**
     * @param array $arguments
     * @param \Closure $renderChildrenClosure
     * @param RenderingContextInterface $renderingContext
     * @return string
     */
    public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
    {
        $newRequest = static::getUsedSearchRequestFromRenderingContext($renderingContext)
            ->getCopyForSubRequest()
            ->removeQueryString();
        $uri = self::getSearchUriBuilder($renderingContext)->getCurrentSearchUri($newRequest);
        return $uri;
    }
}

Fixes: #4135

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Add option to completely remove query-string from SearchRequest
1 participant