69

image url Syntax is ok for both static block and phtml, But make sure that when you write this code in static block <img src="{{view url="images/slide-bg.jpg"}}" alt="test" /> on front end it looks like http://localhost/magento2new/pub/static/frontend/Magento/luma/en_US/images/slide-bg.jpg Where Magento/luma is package name and theme name, you can ...


51

in admin panel go to Content->Pages and edit home page and if you created your static block from admin panel add following to the Content tab {{block class="Magento\Cms\Block\Block" block_id="your_block_identifier"}} and if you created a custom block using a module add following to home page content tab {{block class="Vendor\ModuleName\Block\BlockName" ...


25

Finally I got the solution. You can call static block using following way. <referenceContainer name="footer"> <block class="Magento\Store\Block\Switcher" name="store_switcher" as="store_switcher" after="footer_links" template="switch/stores.phtml"/> <block class="Magento\Cms\Block\Block" name="test"> <arguments> ...


25

add this to the your class: private $blockFactory; and make your constructor look like this: public function __construct( PageFactory $pageFactory, \Magento\Cms\Model\BlockFactory $blockFactory ) { $this->pageFactory = $pageFactory; $this->blockFactory = $blockFactory; } you can even remove the $pageFactory dependency if you don't ...


20

For your custom module create a directory structure like Company/Module/view/frontend/web/images/image-icon.png and in phtml use following code <img src='<?php echo $this->getViewFileUrl('Company_Module::images/image-icon.png'); ?>' alt="image-icon" width="30" height="25">


20

Call your contact form block with template file in the cms pages. Try below code : {{block class="Magento\Contact\Block\ContactForm" name="contactForm" template="Magento_Contact::form.phtml"}}


17

You can get base url in static block like this. <a href="{{store direct_url="business"}}">Your link</a>


16

Use Of {{view url=""}} You have to use view url like below for all images are coming from theme folder, app/design/frontend/{Vendor}/{themename}/web/images/ {{view url="images/natale/IMG_7300.JPG"}} You can use in your static block or page using below way, <img src="{{view url="images/natale/IMG_7300.JPG"}}" alt="" /> Use Of {{media url=""}} ...


14

You can try the following solution: Add 2 classes to the constructor: /** * @var \Magento\Cms\Model\BlockFactory */ protected $blockFactory; /** * @var \Magento\Cms\Model\BlockRepository */ protected $blockRepository; /** * @param PageFactory $resultPageFactory * @param \Magento\Cms\Model\BlockFactory $blockFactory * @param \Magento\Cms\Model\...


13

We can try: {{block class="Magento\\Cms\\Block\\Block" area='frontend' block_id="mail_include_header"}} We can see more how to add a block to email: vendor/magento/module-sales/view/frontend/email/shipment_new.html


12

Easy solution: Put your image on Your Magento 2 Path: /app/design/frontend/< Vendor >/< theme >/web/images Use this code to call the image in phtml file: echo $block->getViewFileUrl('images/demo.jpg');


12

Let's say the block that displays your content is called Vendor\Module\Block\Entity. Add a dependency Zend_Filter_Interface to your block like this: protected $templateProcessor; public function __construct( ... \Zend_Filter_Interface $templateProcessor, ..... ) { .... $this->templateProcessor = $templateProcessor; .... } Then ...


11

in app/code/core/Mage/Page/Block/Html/CookieNotice.php: $block = Mage::getModel('cms/block')->load($blockIdentifier, 'identifier'); Before loading the block, you should set Store ID: $block = Mage::getModel('cms/block')->setStoreId(Mage::app()->getStore()->getId())->load($blockIdentifier, 'identifier'); You can use your local app/code/...


11

First, you need to add the files inside your project so magento can display them on the back office There is two ways : The simplier way : just add your file via ftp to media/wysiwyg/[optional_folders]/[your_file.pdf]. OR Make magento allow pdf files upload on back office. There's two steps : Add pdf to allowed extensions type. With that modification ...


11

Add store direct_url instead of store_url <a href="{{store direct_url='produkte/insektenschutz/fenster/spannrahmen.html'}}"> spannrahmen.html will show after this.


10

try this or else post your code then we will suggest you where you went wrong. Block file <?php namespace Learning\SmartSearch\Block; class SmartSearch extends \Magento\Framework\View\Element\Template { public function getTitle() { return "Smart Search"; } } etc/module.xml <?xml version="1.0"?> <config xmlns:xsi="http://...


10

This issue has actually already existed in Magento 1, it's due to the TinyMCE editor which will just strip invalid HTML from the user input, sometimes it considers a little too much to be invalid, though. Another common issue is that it will create new <p> elements all over the place, can be pretty annoying as well. I recommend checking out Alan ...


9

On __construct function,you need inject \Magento\Cms\Model\Template\FilterProvider \Magento\Store\Model\StoreManagerInterface \Magento\Cms\Model\BlockFactory for getting data. You can try below as example ....... public function __construct( \Magento\Framework\View\Element\Context $context, \Magento\Cms\Model\Template\FilterProvider $...


8

It can be done easily from the admin panel by following the steps below. Go to Content -> Widgets Add New Widget Select type as CMS Static Block Select Design Package/Theme And Continue Set Widget Title, Store and Sort order in Storefront properties tab Select static block from in the Widget options tab Save the widget Click On Add Layout Update button ...


8

Try following: Copy file to your frontend theme and update text as you want. FROM: vendor/magento/module-cookie/view/frontend/templates/html/notices.phtml TO: app/design/frontend/[VendorName]/[themename]/Magento_Cookie/templates/html/notices.phtml


8

Try adding this to your block: <a href="{{store direct_url="produkte/insektenschutz/fenster/spannrahmen.html"}}">Link to Base URL</a>


7

First you login Magento admin -> CMS -> Pages Select your page and input your HTML code as you normally would on any other information you include the page, then select Content tab and add it. The below lines to add your cms -> page: {{block type="core/template" name="contactForm" form_action="{{store direct_url='contacts'}}/index/post" template="...


6

Tipo,as you want using getFirstItem(),it only given 1 item,you need to remove this function and add getAllIds() function on this collection. Full code: $pageIds = Mage::getModel('cms/page')->getCollection() ->addFieldToFilter('identifier', 'your name in the pages') //->getFirstItem() ->getAllIds();) getAllIds()...


6

If you want to call static-block in 2columns-left page, you can simply do it using, here below you can change quickblock with your static-block identifier. <referenceContainer name="sidebar.main"> <block class="Magento\Cms\Block\Block" name="quick-block"> <arguments> <argument name="...


6

You need to go to System -> Permissions -> Variables and add new variable general/store_information/hours as allowed for it to work on frontend. As to why it is like this, I guess they just forgot to add it in app/code/core/Mage/Admin/sql/admin_setup/upgrade-1.6.1.1-1.6.1.2.php: $installer->getConnection()->insertMultiple( $installer->...


6

You can use Magento\Framework\View\Element\Template basic template. Try this: <div id="something"> {{block class="Magento\Framework\View\Element\Template" name="test" template="path/to/my/file.phtml" }} </div> This should work. UPDATE: If you need to display product information you have to use blocks from prduct view. Example: <div ...


6

I got it! The problem was the getById() method it DOES take a identifier as well as the id, my problem was that my test block had the identifier "123" and although it is a string either magento or php reads it as a numeric id in the method. So it is always was searching for the id (int) 123 instead of the identifier (string) '123'. Maybe seperate methods ...


5

Use this: <core_block_abstract_prepare_layout_before> <observers> <ssd_test> <class>ssd_test/observer</class> <method>generateBlocks</method> <type>singleton</type> &...


5

Ok so I have found the cause of this problem and it seems to be a problem in core magento. There is a new _construct method added to Mage_Cms_Block_Block in magento 1.14.2 which contains the following code. /** * Initialize cache * * @return null */ protected function _construct() { /* * setting cache to save the cms block */ $this->...


5

Welcome to Magento.SE! This is quite easy to do and will require that you make a module to rewrite the functionality of Mage_Catalog_Block_Product_New. Once you've done that, you need to just make an edit to the _getProductCollection method modifying the collection: protected function _getProductCollection() { $collection = parent::...


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