How to call theme images from a static block
You call theme images from static block as follows: magento2 : {{view url=”images/demo.jpg”}}
You call theme images from static block as follows: magento2 : {{view url=”images/demo.jpg”}}
To override a base view file in Magento 2, create a file with the following name: app/design/frontend/[VendorName]/[theme]/Magento_Tax/templates/pricing/adjustment.phtml.
base folder is a default fallback for all arias used to share resources across areas.
To add a custom block to specific product type view pages, use product type dependent layout updates catalog_product_view_type_{prodyct_type}.xml (catalog_product_view_type_ grouped.xml). For instance:
1 |
<?xml version="1.0"?> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/layout_generic.xsd"> <referenceContainer name="content"> <block class="..." /> </referenceContainer> </layout> |
Since there is no ‘core’ module in Magento 2, you can do this by following way inside view file (.phtml):
1 |
$this->helper('Magento\Framework\Pricing\Helper\Data')->currency(number_format(50,2),true,false); |
You can put a search box after the navigation block and use css to make display it in one line, since html/topmenu.phtml block doesn’t print its child’s
1 |
<move element="top.search" destination="page.top" after="catalog.topnav" /> |
Alternatively, you can overwrite html/topmenu.phtml to
1 |
<?php $columnsLimit = $block->getColumnsLimit() ?: 0; ?> <?php $_menu = $block->getHtml('level-top', 'submenu', $columnsLimit) ?> <nav role="navigation"> <ul data-mage-init='{"menu":{"responsive":true, "expanded":true, "position":{"my":"left top","at":"left bottom"}}}'> <?php echo $_menu; ?> </ul> <?php echo $block->getChildHtml() ?> </nav> |
Probably, you have a problem related to
Because of Dependency Injection pattern Magento 2 have huge constructors for every class. World best PHP IDE PHP Storm can help you generate constructors and save lots of time in Magento 2 development.
With constructor generator you will be able to create constructors with arguments, with the value assigned to the field variables. Continue Reading
To get a URL from your Magento root directory, use getUrl. Since it inherits from the AbstractBlock class (Magento\Framework\View\Element\AbstractBlock), you are able to use it with any of your blocks. Check the below example:
1 |
$this->getUrl('pub/media/video/', ['_secure' => $this->getRequest()->isSecure()]).$fileName |
The first parameter is the path you need, while the second one sets the _secure option if the user is browsing over https. You can add to the path by concatenating a specific filename onto the getUrl call or you could add it to the first parameter as well. Please note that the path is relative to the root directory of your Magento install.
Below, I shed light on a proper Redis configuration for Magento 2. If you are not familiar with the solution, it is an advanced key-value cache with top notch performance. In addition, Redis is often considered to be a data structure server, which provides the following opportunities:
By using