I have a Magento 2.1.x installation with two store views. I would like to show a particular block in the footer only for one store view.

In Magento 1.9.x I would have done it in this way:

    <reference name="lorem_ipsum">
        <block type="..." />

How can I achieve that in Magento 2?

2 Answers 2


I'm not sure how you can do that in Magento 2, the cleanest way I can think of would be to :

  1. Create a new theme that uses your current theme as a parent
  2. Set your second store to use the new theme
  3. Extend the layout XML in your new theme with your change

You'll end up with the same effect, although it is more work than the method you mentioned for Magento 1.

  • Creating additional theme which results in greater compilation time in production mode while deploying version is a very bad idea. Commented Nov 14, 2017 at 18:34
  • What is so bad with an additional x seconds of deployment?
    – Ben Crook
    Commented Nov 15, 2017 at 9:44
  • 1
    When time means money and every second of maintenance generates debt, where bad solutions like your stacks - it can lead to many problems. It doesn't matter in small scale (however bad solution is a bad solution). Also, depending o theme it can be far more than seconds plus there are still magento bugs eg. with generating translations which may result in repeated deployment. And finally, i will not understand why I would like to create additional theme for something that can be done with one if? Commented Nov 15, 2017 at 10:18
  • If I was aware of that method I would have added it, but I wasn't aware hence I say "the cleanest way I can think of" and not "the cleanest way is".
    – Ben Crook
    Commented Nov 15, 2017 at 10:34
  • 1
    It's no problem, you have a very good point and your answer sounds like the better option. I'm a front-end developer so I don't work with deployments too much hence my answer isn't great. It's the joys of stack exchange, you get a wide variety of answers.
    – Ben Crook
    Commented Nov 15, 2017 at 10:42

Instead of doing it in layout xml which is not possible in M2 you can either override/plugin toHtml method in block and implement required logic or add such a logic as separate method in block to call in if/else structure inside of phtml file.

  • Hm, how exactly can you override the block class of an existing block?
    – fritzmg
    Commented May 24, 2018 at 10:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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