22 votes

Magento 2 - How to create FAQ page with accordion

It is possible. If you want to use data-mage-init Then you do it like this: <div id="element" data-mage-init='{"accordion":{"openedState": "active", "collapsible": true, "active": false, "...
iva's user avatar
  • 471
16 votes
Accepted

Magento 2: Call a Widget in a .phtml file

For Display Type = All Product Widget {{widget type="Magento\Catalog\Block\Product\Widget\NewWidget" display_type="all_products" products_count="5" template="product/widget/new/content/new_grid....
PG Sutariya's user avatar
15 votes

Magento2: How to override widget template

you can extend the widget in your module. To do that your module has to depend on the module where the original widget is defined (see sequence in the module.xml). Then you create a widget.xml in ...
David Verholen's user avatar
11 votes
Accepted

Magento 2 Modal Widget

Try following way. <script> require( [ 'jquery', 'Magento_Ui/js/modal/modal' ], function( $, modal ) { ...
Sohel Rana's user avatar
  • 35.8k
11 votes
Accepted

Magento 2: How to put default value in yes/no field of widget.xml in magento 2?

If default values are not working for YesNo (I don't have time to dig) then you could always cheese the system for the time being and try to find a cleaner solution: <parameter name="chart_layout"...
Julien Lachal's user avatar
8 votes

Magento2: How to override widget template

You can replace the grid.phtml where you call the widget {{widget type="Magento\CatalogWidget\Block\Product\ProductsList" title="Our Products" products_count="8" template="Namespace_Modulename::...
Dharmendra Jadav's user avatar
7 votes
Accepted

Component vs Widget

The widget can be initialized with a few lines of JS, where as the component requires many lines of XML and still uses the widget. So why would anyone use the XML method? The UI component system ...
Alana Storm's user avatar
  • 44.4k
7 votes
Accepted

How to call widget with products of specific category in ".phtml" file?

There is a widget for arbitrary product lists (as mentioned by @Nits). If you insert the widget on any CMS page or block and turn off the WYSIWYG editor ("Hide editor" button), you can see how the ...
Fabian Schmengler's user avatar
7 votes

How to remove ‘Add New’ button from Admin Grid in Magento 1.9?

Renate, if you are following the tutorial, then you'll need to add the code suggested by Rama to this section <?php class Foo_Bar_Block_Adminhtml_Baz extends ...
pjw345's user avatar
  • 71
7 votes
Accepted

How to pass a variable to a JS widget in Magento 2

You can get the values passed from phtml to widget in any function using below code, this.options.ajaxShipmentUrl
aravind's user avatar
  • 1,844
6 votes

How to call widget with products of specific category in ".phtml" file?

You can do it via static-block: 1) add static block with widget of catalog product list and add category id in widget condition. (content menu >> Blocks >> add new >> click on show/hid button >> ...
Nits's user avatar
  • 2,496
6 votes

Magent2 Modal Widget - change width and height

You can use 'modalClass' option to set a custom css class to your modal popup und define width in the css: .my-custom-class .modal-inner-wrap { width: 600px; }
alexblum's user avatar
  • 417
5 votes
Accepted

How to use tabs widget in magento2

You have error on the page because you miss your tabs widget in dependencies list (at list if you want to use Magento's tabs widget). Correct: require([ 'jquery', 'mage/tabs' ], function($){ ...
Anton Huz's user avatar
  • 350
5 votes

Add javascript in custom widget

Create requirejs-config var config = { map: { '*': { yourWidgetName: 'NameSpace_ModuleName/js/yourwidgetfile', } }, }; Define you widget following convention ...
mrtuvn's user avatar
  • 3,273
5 votes

How to remove ‘Add New’ button from Admin Grid in Magento 1.9?

Try like this TBF_Cupom_Block_Adminhtml_Gerados_Index extends Mage_Adminhtml_Block_Widget_Form_Container { public function __construct() { ..... $this->_removeButton('add'); } } Note: ...
Rama Chandran M's user avatar
4 votes

Magento 2 - How to create FAQ page with accordion

This works for me : <div data-mage-init='{"accordion":{"openedState": "active", "collapsible": true, "active": false, "multipleCollapsible": false}}'> <div data-role="collapsible"> ...
Laurent Khoudja's user avatar
4 votes
Accepted

Magento2 Add to Cart from homepage not working

The solution (for no clarified reason) was to enable all Magento caching options. This solved the issue for me. Tested this again in a new install: Fresh Luma templated with new product widget on the ...
Rann's user avatar
  • 331
4 votes
Accepted

How to render widgets in product and category description in Magento 2?

Instead of instantiating the object manager and filterprovider etc. in your template, consider this: In your block class (Vendor\Module\Block\Widget\CustomWidget) include the dependencies in your ...
Giel Berkers's user avatar
  • 12.2k
4 votes
Accepted

Magento 2 : </depends> is Not Working in Widget.xml

The problem is that the JS that handles the show/hide functionality of dependency elements doesn't find anything in the case of xsi:type="block" fields. One way to get around this is to override the ...
Aaron Allen's user avatar
  • 9,009
4 votes

Magent2 Modal Widget - change width and height

<a href="javascript:;" class="bt-action" data="More Info" >More Info</a><div class="bt-action-file" style="display: none;">Content here</div> require( [ ...
Sarvesh Patel's user avatar
4 votes
Accepted

Magento 2: insert a "Bestsellers" widget via the Magento admin

I have created something similar using following code. app/code/Anshu/Bestsellerwidget/registration.php <?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\...
Anshu Mishra's user avatar
  • 8,950
4 votes
Accepted

Magento 2 decode widget code in category description

you need to pass the content of the description inside a function before the display. This filterProvider will replace the widget code inside the content of the description. public function ...
Taschert's user avatar
  • 569
4 votes
Accepted

Magento 2 Confirmation widget confirm action

This is because you have called echo $block->activateUser('$userId'); inside it. The correct way should be if you call ajax to a controller and put your logic for activateUser in it. Something like ...
Prachi Saxena's user avatar
4 votes

Use slide animation for opening tabs or accordions

Finally figured this out, but not in the way that I was hoping. My goal was to do this in my .js file, but I could only get the animation to work but putting the animation in the data-mage-init object ...
mlunt's user avatar
  • 575
4 votes
Accepted

Magento 2: add magento widget button on product WYSIWYG editors

Here’s an example on how to do it for the Description field. You can use it for other WYSIWYG fields in the product edit page (just modify the condition for the IF in step number 2 and add the filter ...
Daniel Kratohvil's user avatar
4 votes

Magento 2 add ViewModel to product widget

You can use a plugin on the widget Block to set a viewmodel. Here is an example of a ProductsList widget with an added viewmodel: Create plugin and define it in di.xml <?xml version="1.0&...
Script99's user avatar
3 votes

Magento 2 - catalog product list widget product order

If you want order by position in the widget product list, you must do the next. Namespace/CustomWidgets/etc/frontend/di.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/...
raumatbel's user avatar
  • 1,235
3 votes
Accepted

How to introduce a new type for widget parameter in Magento2?

Found the solution and wrote a blog post http://mageclass.com/quick-tip-how-to-use-image-wyswyg-or-any-other-non-standard-field-in-magento2-widget/. I am not sure if it's in line with the best ...
mstojanov's user avatar
  • 311
3 votes

Magento 2 - How to create FAQ page with accordion

I think you are having an issue with data-mage-init when saving or edit the content of the CMS page back. You can use accordion in CMS page by adding accordion js to your custom theme. Add accordion ...
Vikram Kumar's user avatar
3 votes

How does Luma theme home page work?

Pretty straight relation which invokes home-page-block, is Widgets. Content -> Widgets -> Now click on Home Page widget. Storefront Properties -> Layout Updates -> specific page Widget Options -> ...
Krishna ijjada's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible