wintercms / docs

The Winter CMS documentation
https://wintercms.com/docs
Creative Commons Attribution 4.0 International
37 stars 69 forks source link

Document how to override views of anything in the backend (widgets, controllers, etc) #195

Closed LukeTowers closed 2 months ago

LukeTowers commented 3 months ago

In Winter it's very easy to override specific view files for anything that uses the ViewMaker trait.

\Backend\Widgets\Filter::extend(function ($widget) {
     $widget->addViewPath(__DIR__ . '../widgets/filter/partials');
});

now you can override any existing partial or even provide a new partials for that widget. You can also get fancier by controlling when exactly you call addViewPath() and on which specific instances of whichever class you're trying to override. The above example was placed in a controller's constructor in order to only extend the filter widget for that specific controller, but it could have easily been placed in the index() method to further limit, or various events could have been listened to in order to further limit the overriding of the partials.

^

TODO: Document that in an easy to find and easy to read way. @damsfx @WebVPF any suggestions?

WebVPF commented 3 months ago

@LukeTowers There is a proposal to merge the develop branch into 1.2 and update documentation on the site https://github.com/wintercms/docs/compare/1.2...develop

damsfx commented 2 months ago

@LukeTowers Not really! Maybe in the "Backend (Admin) > Views & Partials" section or in the "Plugins" section under a new heading "Extending Backend". ¯\(ツ)