Designing the webpage can be done in the app/design
directory in Magento 2 – these are theme related files. I’ve got a question about how to deal with the scenario when additional data needs to be displayed in the template?
I can’t paste the ViewModel
to the app/design
directory; instead I have to have a module. But creating a module just to accommodate the ViewModel that will be used in the theme file seems like an overkill.
Also it is hard to come up with a meaningful module name that would be suitable for this reason. One of the ideas behind using ViewModel
is the fact that it is reusable; so I shouldn’t really just create a module called Checkout
to hold a ViewModel
that would be used in the checkout. It can be used everywhere else.
However if I create a super vague module name like TemplateDataProvision
then it will grow overtime and will contain tons of ViewModel
files; some sort of a dumpster.
And I don’t really find it feasible to create a very specific module that’s role is to hold a one or a few ViewModel
classes only; since we’ll end up having a repo that holds tons of modules that just have a ViewModel
. A module’s role is to provide some sort of functionality. ViewModel
per se is not enough for the module, imho.
That being said, where should it go? Perhaps there is a way (that I am unaware of) to chuck it in the app/design
after all? If not, then how do you guys solve this dilemma?