If we want to add Owl Slider in Magento 1.X then we follow the below steps.
- Copy
owl.carousel.min.js
andowl.carousel.js
and paste intoskin/frontend/pakage_name/theme_name/js
- Copy
owl.carousel.css
and paste intoskin/frontend/pakage_name/theme_name/css
- Goto
app/design/frontend/pakage_name/theme_name/layout/page.xml
and call js and CSS
And we can use Owl Slider anywhere in Magento 1.X site.
So in Magento 2 how we can call Owl slider and it should be called everywhere in the site so I can use whenever I want.
For this problem, I have referred this link but it's not up to the mark and it's not working.
Right now I have placed Owl slider js in app/design/frontend/pakage_name/theme_name/Magento_Catalog/web/js
but it's not working.
Any help would be appreciated.
Best Answer
You have to created one
requirejs-config.js
file inside your theme like,First Add owlcarousel.js file inside,
Add your css inside,
call css inside your tempalte file using,
or call css inside a layout file (best practice), depending on your needs :
default.xml
for exampleapp/design/frontend/pakage_name/theme_name/Magento_Catalog/layout/default.xml
cms_index_index.xml
Now create requirejs-config.js file
Define your slider,
Now you can use owlcarousel under any phtml file,
Remove pub/static folder content and run
php bin/magento setup:static-content:deploy
command.