I am confused about when to override things from my module and when from my theme.

I am creating a module in which I am changing the checkout functionality. I am using js-mixin, creating blocks and adding translations. I also need to override layout and template files, which is crucial and cannot exist independently without my mixins and blocks from the module.

The problem is that most (read "all") of the tutorials suggest overriding templates and layouts from a theme. For me, it doesn't make sense to add some things in the theme and some in the module if they cannot exist independently.

Is there anything wrong with overriding templates and layouts from a module (Im assuming there is a way to do it, I just haven't found it yet)?

EDIT
Only just found this answer here, does add some clarity.

up vote 2 down vote accepted

Simple difference between both is !!

A module is a type of component. A component can be:

A module - code that extends/expands Magento functionality behavior

A theme - changes the look and feel of your Magento Admin or storefront

So if you think you can achieve some functionality or overrides the template in module then you can use module as well !!

Concept is - for theme you can change/override those things which is related to layouts and template system where in module you can override the code and enhance the native functionality.

  • Thanks! But what if my layout/template changes relay on something that is added in my module. Then it surely would make sense to add this dependent layout/template in the module and not have it separately in the theme, right? Because technically it will be changing the look, but it cannot function without the added functionality from my module. – Jurģis Toms Liepiņš Mar 12 at 12:05
  • 1
    @JurģisTomsLiepiņš - Yes agree , when you have templates changes which is relay on your custom module then you don't need to create theme . you need to override that specific template into your custom module only !! that's why when we need to change layout/template we are using theme because from there we can find all the files related to template . where in if something we need to find on functionality level then we will get that seperetly from custom module. – Manthan Dave Mar 12 at 13:15

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.