Fetching data at every page call

Got a Twig template for a small product finder. It’s displayed on every page of the webseite.
The data displayed in it is fetched from database and enriched with some additional things before assigned to the view.

Where should I add that global functionality, that is called at any page? My idea is the BaseController inside the onKernelController() Function? Or is there a better and more practicable way?

Thx a lot in advance!

twig extension is what you are looking for

Hi Dominik!
Thx for your answer. That’s an idea, yes. But I want to be independent from Twig…

I think that’s unfortunately not what I’m looking for. My question regards on the controller part of Pimcore. Twig is just the view. What I need is an opportunity to fetch and handle data without regarding the view.

Perhaps you’ve got another good idea? :slight_smile:

then create a service that gets injected into the twig service, that way you are independent.

Okay, thx. Sounds like an good idea. Gonna let you know when it works :slight_smile:
Thx a lot again :wink: