I am wondering if there is a way to replace or hide a certain div with a module.

I'm not talking about a whole new .phtml file. If you can make a part phtml file thats fine but i don't know how. It needs to work with a theme so i want to make it more universal then just copy/pasting the .phtml file and adjusting it.

Is there a way to replace a part of a template only?

More in detail i want to delete :

<form data-role="tocart-form">

Thanks for your time of you are anwering this.

This is for Magento 2

  • I'm pretty sure you will have to replace the entire phtml and adjusting it, but if there is another way here I am. – slayerbleast Jun 20 '17 at 15:54

I'm not too sure what you're asking, it sounds like you want to remove or hide an element only inside a template?

I'm not sure why you'd want to do this, if you want to hide it then use CSS and if you want to remove it then either remove the block via XML or remove the markup in the template by overwriting it. Here is an answer on how to override a template with your module.

  • I want too delete the tocart-form. Not hide it with css because that is just unsecure and a bad method as far as i see it. – CompactCode Jun 21 '17 at 9:56
  • And that to cart form is rendered within the .phtml fille – CompactCode Jun 21 '17 at 9:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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