How do I change the response view?

For responses that return HTML, a Twig view file is used. Whilst these are originally defined, the view can be changed. For example, to change the product page view based on product data:

\Aero\Store\Http\Responses\ProductPage::extend(function ($page) {
    if ($view = $page->product->additional('view')) {
        $page->setView($view);
    }
});

Setting the view to nullwill result in a JSON response.

You can get the current view for a response using $page->getView().


Revision #1
Created 2026-09-02 13:29:04 UTC by Michael Price
Updated 2026-09-02 13:29:05 UTC by Michael Price