Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMS page add block magento

Tags:

magento

block

I have in CMS->page "home page" file. In content i am writing line like this:

{{block type="myfolder/newfile" template="myfolder/newfile.phtml"}}

I want to render in content file newfile.phtml. What i am doing wrong ?

My new file is under: app\design\frontend\default\themeas\template\myfolder\newfile.phtml

like image 567
andys Avatar asked Apr 10 '12 14:04

andys


People also ask

How do you call CMS blocks in CMS?

Call phtml using block codeOpen any cms page and write block code in content section. After using the block code phtml file will be called on cms page. If you want to call phtml file on all cms pages then you can create a layout file to achieve this. create layout “cms_page_view.

How can I add block site in Magento 2?

In order to add HTML block at the top of the page please go to Admin Panel > Content > Blocks and press the Add New Block button. Then Enable the block, set its Title and unique Identifier. Choose what Store View will your block be enabled on.


2 Answers

Since Magento 1.9.2.2, or equvivalent patch you also need to grant permissions to the new block. You do this in the backend: System | permissions | blocks

I.e if you wish to show:

{{block type="catalog/product_bestseller" name="krillo.bestseller" template="catalog/product/bestseller.phtml"}}

Add your block name "catalog/product_bestseller" and set the status to "allowed"

like image 196
kaptenkrillo Avatar answered Sep 29 '22 10:09

kaptenkrillo


I'd like to offer an alternative:

The above answers work fine, however it's my personal preference to not insert blocks in the content of a CMS page as clients can (and have) deleted this crucial line when trying to edit text and content using the WYSIWYG.

You could add the following in the the Layout > Layout update XML section of a CMS page:

<reference name="content">
    <block after="-" type="your/block_type" name="block.name" template="your/block/template/file.phtml"/>
    <action method="insert" ifconfig="your/block_type">
        <block>block.name</block>
    </action>
</reference>

This way, clients are less likely to edit this tab!

Hope this helps anyone else with this issue!

like image 34
Chris Rogers Avatar answered Sep 29 '22 11:09

Chris Rogers