3

How can the HTML files from the library be overwritten?

I need to overwrite this template:

  • lib/web/mage/gallery/gallery.html

I have tried placing the file in my own theme in the below locations, I've cleared my cache between each file move.

  • app/design/frontend/**VENDOR**/**THEME**/web/mage/gallery/gallery.html
  • app/design/frontend/**VENDOR**/**THEME**/web/gallery/gallery.html
  • app/design/frontend/**VENDOR**/**THEME**/web/lib/mage/gallery/gallery.html
  • app/design/frontend/**VENDOR**/**THEME**/web/lib/gallery/gallery.html
  • app/design/frontend/**VENDOR**/**THEME**/mage/gallery/gallery.html
  • app/design/frontend/**VENDOR**/**THEME**/web/template/gallery/gallery.html

I've read through the dev docs and can't see anything mentioned in there either.

  • could you help me to find difference between lib/web/mage/gallery/gallery.html and vendor/magento/magento2-base/lib/web/mage/gallery/gallery.html? – LucScu Sep 29 '16 at 12:47
  • @LucaS I believe /lib and /vendor/magento/magento2-base/lib are the same. If you check all the files there I think they will all be identical. – Ben Crook Sep 29 '16 at 14:55
  • Yes, so why if they are identical they are both in magento project? What is their different purpose? – LucScu Sep 30 '16 at 10:42
  • 1
    I'm not sure, I think it's the way Composer installs packages. Everything is installed to /vendor, so I'd take a guess that it copies the lib from the vendor magento2-base directory into the lib. – Ben Crook Sep 30 '16 at 12:28
  • i think your answer is rational, i take it as mantra :) – LucScu Oct 1 '16 at 14:53
10

Correct Location

The correct location in this example is actually the first one I tried, I just didn't clear the directories required. So to overwrite lib templates they need duplicating in to the theme directory excluding the lib directory.

Correct location -app/design/frontend/**VENDOR**/**THEME**/web/mage/gallery/gallery.html

Clear pub/static and var/view_preprocessed

I actually placed the file in the correct location the first time, the main issue I had was that I wasn't clearing pub/static and var/view_preprocessed between file moves.

  • The correct location is already stated in the list of locations you tried in your question. Clearing the folders only fixed your problem or you typed the wrong locations ? – Raphael at Digital Pianism May 23 '16 at 10:44
  • I believe my problem was I didn't clear pub/static and var/pre_processed. I thought clearing the cache was enough before I remembered the html templates are classed as static assets. – Ben Crook May 23 '16 at 11:09
  • 1
    I've updated the answer to make it a bit more obvious. – Ben Crook May 23 '16 at 11:11
  • @BenCrook how can i override this file lib/web/mage/adminhtml/browser.js ? – ND17 Jul 18 '17 at 6:04
  • 2
    @ND17 I haven't done anything with the adminhtml so this is a guess: app/design/frontend/**vendor**/**theme**/web/mage/adminhtml/browser.js – Ben Crook Jul 18 '17 at 8:25

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.