Component rendered in a partial cannot redirect

Since I would like to fill by sidebar with several custom widgets, I created a few sidebar partials which load those widgets. One of them is a little search component, which simply take the search term, validates it and pass it as an urlquery to the main search page.

However, everything works fine, just the Redirect::to() is not performed.

If I render this component in the page directly, it works, so I guess it has to do with the Redirect::to() within a component which is rendered in a partial.

How can I solve this?

If there’s a better idea how I can do my sitemaps, I’m open for ideas, too ^^

    public function onRun()
    {
        if ($this->getInput()) return;

        $queryParameters = ['searchterm' => $this->searchterm];
        $queryString = http_build_query($queryParameters); 
        $url = ($this->pageUrl($this->searchPage) . '?' . $queryString); 

        // TODO: Redirect dont work if the component is used in a partial. Works in page!
        return Redirect::to($url); 
    }

I could solve my problem:

For unknown reasons, I’ve setup the form in the sidebar like this:
{{ form_open({'url': this.page.id | page, 'method': 'post'}) }}

and then checked for the input in the onRun() and wanted to do a redirect.

Honestly, no idea why I did this so complicated while I could simply do this:

{{ form_open({'url': searchPage| page, 'method': 'get'}) }}

I have a “real” search page where you can perform detailed searches and all which this small component in the sidebar should do is redirect to it. Well… so whyever I decided to redirect to the same page and then pass the stuff further - I could also have redirected to the search page directly and send the parameters with GET, and that’s it:

Problem solved ^^

1 Like