@Mayur Bhuva wrote:
You can call your custom js file in
app/design/frontend/vendor/theme/Magento_Catalog/layout/catalog_category_view.xml
<?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <head> <script src="Magento_Catalog::js/custom.js" /> </head> <body> </body> </page>Now create your custom.js file at following location
app/design/frontend/venodr/theme/Magento_Catalog/web/js/custom.js
Now add the javascript code in this custom.js file.
After that, run the deploy command
php bin/magento s:s:d -f
@Mayur Bhuva
Thanks also for this reply.
But I must be doing something wrong, because I can't get is working:
1. I added the custom js file: http://prntscr.com/l0hbxy
2. I added that to the head of the catalog_category_view.xml : http://prntscr.com/l0hcbl
3. I added the html to the category content section: http://prntscr.com/l0hcsp
But still on frontend it still shows the old text with the old html, as of nothing has changed: http://prntscr.com/l0hdba
Thanks once again ;-)
I can't get it working.
1. I added the custom js file to your suggested location, see screenhot: http://prntscr.com/l152zf
2. Then I call it from the catalog_category_view, see screenshot: http://prntscr.com/l153yw
3. Then I added the HTML code to the Category Content Description box in the backend, see screenshot: http://prntscr.com/l154z3
But then on front-end it is still showing the old content for that category text, see screenshot: http://prntscr.com/l155vs
I must be doing somewhting wrong or overlooking something
You can simple put the code on your theme under catalog module.
Magento_Catalog/view/frontend/templates/category/description.phtml
<p><button class="show-hide-minimized-content">Show/Hide Text</button></p> <p class="minimize-text" style="display: none;">This is the content which you want to minimize.</p> <script type="text/javascript"> require(['jquery'], function($){ jQuery(document).ready(function(){ jQuery('body').on("click", ".show-hide-minimized-content", function(){ jQuery(".minimize-text").toggle(); }); }); }); </script>
@Jignesh Chauhan wrote:
You can simple put the code on your theme under catalog module.
Magento_Catalog/view/frontend/templates/category/description.phtml
<p><button class="show-hide-minimized-content">Show/Hide Text</button></p> <p class="minimize-text" style="display: none;">This is the content which you want to minimize.</p> <script type="text/javascript"> require(['jquery'], function($){ jQuery(document).ready(function(){ jQuery('body').on("click", ".show-hide-minimized-content", function(){ jQuery(".minimize-text").toggle(); }); }); }); </script>
@Jignesh Chauhan
Sorry, but I can't find that specific path. I got this path: http://prntscr.com/lbdabo
but it doesn't match with your suggested path. I'm trying hard but can't get it to work yet. Anyone?
Anyone?
Anybody alive out there? ;-)
I still wasn't able to resolve this. Can anyone be a little bit more precise?
Anyone maybe can help me out and explain this a bit more indept?