10 votes
Accepted

magento 2 - How to create a custom "admin" block and display it on an existing Admin page?

Traditional location for admin blocks is (Example): app/code/YourVendor/YourModule/Block/Adminhtml/... If you'd like to use block with phtml template you'd like to extend \Magento\Framework\View\...
Sergii Ivashchenko's user avatar
10 votes
Accepted

Add custom block in Magento 2 admin dashboard

You can try to create a custom module that adds the a block there. Create: \app\code\Custom\Module\registration.php: <?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\...
Adrian Z.'s user avatar
  • 707
7 votes
Accepted

Magento2 not getting post data from ui component phtml file

You have to just add data-form-part="forrname_form" in your input filed forrname_form it's must be similar with your ui form name your code shold be like now: <tr> &...
Rutvee Sojitra's user avatar
7 votes
Accepted

Magento2: How to call custom block in phtml file

Call phtml like this below way : <?php echo $block->getLayout() ->createBlock('Codism\Csr\Block\Index\TopMenu') ->setTemplate('Codism_Csr::menu.phtml') ->toHtml(); ?> ...
Rohan Hapani's user avatar
  • 17.3k
6 votes
Accepted

Magento2 loading admin layout and template in a new page

Your file name needs to be changed like this: From vendor_gift_index.xml To gift_gift_index.xml
Keyur Shah's user avatar
5 votes

How to include module's CSS in CMS pages with module block

Put your js file in your custom module Vendor_Module/view/frontend/web/js/yourjsfile Create requirejs-config.js file in your custom_module/view/frontend. add below code in it . var config = { "...
Manthan Dave's user avatar
  • 9,816
5 votes
Accepted

How to add a custom block within checkout cart summary in magento 2

You need to create this file in your custom module/theme to add custom Block on cart page. app/code/Vendor/Module/view/frontend/layout/checkout_cart_index.xml Content for this file is.. <?xml ...
Kishan Savaliya's user avatar
4 votes

Calling to custom block from cms page display blank page

Two things you really need to check here. You need to whitelist your custom block brandproducts/brandproducts. See this answer for more information. This is required for Magento 1.9 and greater. Make ...
Rajeev K Tomy's user avatar
4 votes
Accepted

jQuery-ui autocomplete: Cannot read property 'element' of undefined

There is issue with Magento2 autocomplete in consequence of extending of base jquery-ui widget by Magento application. More details by link: Magento 2 & JQuery.UI.Autocomplete
Max's user avatar
  • 4,044
4 votes
Accepted

Where is Content block for <reference name="content" tag

For the regular frontend pages the content block is defined in the app/design/frontend/base/default/layout/page.xml: <default translate="label" module="page"> <label>All Pages</...
Siarhey Uchukhlebau's user avatar
4 votes
Accepted

Create block between header and main

I have tried and its working for me. <referenceContainer name="page.wrapper"> <container name="page.wrapper.second" as="page_wrapper_second" htmlTag="div" htmlClass="my-custom-div" ...
Nikunj Vadariya's user avatar
4 votes
Accepted

Magento 1 - Pass multiple variables to view

$foo = array(); $foo['currentTime'] = date("H:i", time()); $foo['someValue'] = 123; $this->loadLayout(); $this->getLayout() ->getBlock('newsletter_popup') ->assign('foo'...
Eugene Kapelko's user avatar
4 votes
Accepted

How to add a custom block after product info in product view page magento2?

Why you need phtml, You can directly call static block. You can use below code in: [VENDOR_NAME]/[THEME_NAME]/Magento_Catalog/layout/catalog_product_view.xml <referenceContainer name="product....
Pawan's user avatar
  • 5,846
4 votes
Accepted

Move Custom tab at top of left sidebar customer dashboard

Hope you doing well. I'm also facing this issue but after some time have solved this. Follow mentioned steps. create file at view/frontend/layout/customer_account.xml. <?xml version="1.0"?> &...
Bhavin Gehlot's user avatar
4 votes

Magento2: Custom module not working

There are a few problems in your module: You have used Outdoor_Configurator in module.xml but in Controller, Block, and layout you have used Vendor_Module. registration.php is missing from the code ...
Mohit Kumar Arora's user avatar
4 votes
Accepted

Magento 2.3 add custom block under each product in category page

Create di.xml file at /app/code/Vendor/Module/etc/frontend/di.xml : <type name="Magento\Catalog\Block\Product\ListProduct"> <plugin name="block-product-list" type="Vender\Module\Plugin\...
Rohan Hapani's user avatar
  • 17.3k
3 votes
Accepted

Custom Block generating an error on template: Magento

After trying to execute the given SQL query in phpmyadmin for a default Magento database, I got the following error: #1054 - Unknown column 'e.name' in 'field list' What this means is that the ...
V.S's user avatar
  • 904
3 votes

Disable page cache for a single block

You can't disable single block cache like in magento 1, Magento recommends handling customer related data via ajax. So you need to create an api endpoint or section data and use javascript to ...
Gosu Przmak's user avatar
3 votes
Accepted

Magento2 - Error: Can't find custom block

Make sure you have the case correct. I.e. Register, not register. – Smartie Thanks Smartie the issue was the wrong case for my module. I created folders with lower case and used upper case in code. ...
ClassMP's user avatar
  • 1,793
3 votes

Move custom block immediate after nav

Use top.container instead of content as a reference. top.container is a container within the header element, just below the top menu.
Fabian Schmengler's user avatar
3 votes
Accepted

Magento 2: How to add custom form on category page?

Create catalog_category_view.xml and call your custom form block app/code/Vendor/Module/view/frontend/layout/catalog_category_view.xml <?xml version="1.0"?> <page xmlns:xsi="http://www.w3....
Prince Patel's user avatar
  • 22.7k
3 votes

how to set custom template in custom block file in magento 2

You can set template by call in your xml like: <block class="Magedelight\EWallet\Block\Customer\Addmoney" name="customer_add_money" as="customer.add.money" template="Magedelight_EWallet::customer/...
Birjitsinh Zala's user avatar
3 votes

How to add a custom block within checkout cart summary in magento 2

You need to create layout file checkout_cart_index.xml at below path and paste this below code : app/code/VendorName/ModuleName/view/frontend/layout/checkout_cart_index.xml <?xml version="1.0"?&...
Rohan Hapani's user avatar
  • 17.3k
2 votes

$product->getOptions() returns empty result

The problem is that the product is not fully loaded in your block. The load() method makes sure that all information of an object is loaded. If you only use loadByAttribute() or a collection, this is ...
simonthesorcerer's user avatar
2 votes

$product->getOptions() returns empty result

Try this: if (Mage::registry('current_product')) { $product = Mage::registry('current_product'); } else { $product = Mage::getSingleton('catalog/product'); } if ($product->getId()) { ...
Abdul's user avatar
  • 9,702
2 votes
Accepted

Calling to custom block from cms page display blank page

Your block should extend from product list I believe. <?php // app/code/local/Compx/Brandproducts/Block/Recentproducts.php class Compx_Brandproducts_Block_Brandproducts extends ...
Adarsh Khatri's user avatar
2 votes

Get Product Collection based on brand parameter from cms page

Add bellow code in your file app/design/frontend/your_package/your_theme/template/catalog/brand/brandprod_listing.phtml If your product attribute brand input type text then add bellow code. <?...
Abdul's user avatar
  • 9,702
2 votes
Accepted

Get Product Collection based on brand parameter from cms page

This should help you: {{block ... my_var="value here" ... template="catalog/brand/brandprod_listing.phtml"}} If you want to get the my_var in php block directly in php block file then try this: $...
Adarsh Khatri's user avatar
2 votes
Accepted

Function call returning fatal error: Call to undefined function getRecentProducts()

EDIT: I tested your code on a local installation, I assume you copied it from somewhere. The problem there is that - is not really a minus but some different special character (I haven't investigated ...
fmrng's user avatar
  • 3,398
2 votes
Accepted

Is this the correct way to add a custom block to before_body_end only on homepage?

The template location is wrong. Assume that your template is located at app/design/frontend/Your_Pakage/Your_Theme/template/page/html/custom_code.phtml. Magento,design fall back logic it would be ...
Amit Bera's user avatar
  • 77.4k

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