In Magento 2, you can assign a CMS block to a category. Usually it appears above the products. By modifying the file catalog_category_view.xml, you can move the block below the product list. Copy the file vendor/magento/module-catalog/view/frontend/layout/catalog_category_view.xml into your child theme…
Using jQuery and domReady in a static block or CMS page (Magento 2)
Using jQuery in a Magento 2 static block or CMS page can be tricky, a special syntax is required. Use the following code to add jQuery when all the content was loaded: Of course, you can skip listening to domReady…
Using jQuery with domReady in a CMS page or static block (Magento 2)
Want to use jQuery in a static block or CMS page? No problem! Open the page or block in Magento 2 admin and insert the following code:
|
1 2 3 4 5 6 7 8 |
<script> require([ 'jquery' ,'domReady!' ], function ($) { console.log('whatever'); }); </script> |
If you do not want to wait for the domReady event, simply…
Referencing a static block from a CMS page (Magento 2)
Want to reference a static block on a Magento 2 CMS page? Just insert the following snippet into the content editor to render the static block identified by block_identifier anzeigen zu lassen.
|
1 |
{{block class="Magento\\Cms\\Block\\Block" block_id="block_identifier"}} |
Adding a static block to a CMS page (Magento 1)
Use the below code to add a Magento block to your CMS page.
|
1 |
{{block type="cms/block" block_id="block_id"}} |
Removing block from cache (Magento 1)
To remove a certain block from the Magento cache, use the below code.
|
1 2 3 |
<reference name="name.of.the.block"> <action method="setCacheLifetime"><s>null</s></action> </reference> |
Getting a blocks HTML in a template (phtml) (Magento 1)
The below code shows how to echo the HTML of a block with the id ‘my_block’.
|
1 |
echo $this->getLayout()->createBlock('cms/block')->setBlockId('my_block')->toHtml(); |
Adding a static block to the sidebar (Magento 1)
Using the folowing layout update, you can add a static block to the left sidebar:
|
1 2 3 4 5 6 |
<!-- left --> <reference name="left"> <block type="cms/block" name="STATIC_BLOCK_NAME"> <action method="setBlockId"><block_id>STATIC_BLOCK_ID</block_id></action> </block> </reference> |
Sending parameters to a static block (Magento 1)
You have to use so called filters to send parameters to a static block from a template for example. Lets take a look at the following code: Thats the static Magento block:
|
1 2 3 |
<a href="{{store url=''}}{{var attribute_set_name}}/configuration/test/product_id/{{var product_id}}"> Configure </a> |
We want to send attribute_set_name and product_id…
Using skin, media, … URLs in blocks or CMS pages (Magento 1)
The following 4 examples show how to get the skin, media, base and store URLs in a MAgento block or CMS page: skin: {{skin url=’images/sampleimage.jpg’}} media: {{media url=’/sampleimage.jpg’}} base: {{base url=’yourstore/mypage.html’}} store: {{store url=’mypage.html’}}