magento2 - Magento 2 - How to add additional js files to product page only -
magento 2 use requirejs , different approach version 1. therefore, if want keep using default theme luna, extend product page adding 1 javascript file. best way do?
should extend creating new module?
--update-- after thinking question above, here, i'm listing in steps follow. need find way , solution. since i'm new magento 2, questions might simple you, please don't mind give help. thanks!
create child theme , use luma theme parent. (i'm studying http://devdocs.magento.com/guides/v2.0/frontend-dev-guide/themes/theme-create.html there many questions in detail on how locate js file)
magento 2 use requirejs. best way put js file, such as, if have js file trigger events on product variation changes. , js file named custom-events.js. should put?
--update-- created child theme of luna, ie: named as: vendor , lunachild:
app/design/frontend/vendor/lunachild/theme.xml app/design/frontend/vendor/lunachild/registration.php app/design/frontend/vendor/lunachild/etc/view.xml
how place catalog_product_view.xml in theme?
you can add js throught xml layout. have override catalog_product_view.xml
local theme.
<?xml version="1.0"?> <!-- /** * copyright © 2015 scommerce mage. rights reserved. * see copying.txt license details. */ --> <page xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:nonamespaceschemalocation="urn:magento:framework:view/layout/etc/page_configuration.xsd"> <head> <link src="custom_module::custom.js"/> <css src="custom_module::custom.css"/> </head> <body/> </page>
also can add css or js using require.js , using head.additional block
Comments
Post a Comment