25

I have read different tuts about this and some say it all can be done from the admin panel, others say I have to add code in my layout and in the template files. Well, nothing works...

  1. I created the static block from admin > CMS > static blocks with identifier home_image-center
  2. Found the template app/design/frontend/enterprise/my_theme/template/cms/home.phtml and in the place where I want the block to stand I wrote this code:

    <div>

    <?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('home_image-center')->toHtml();?>

    </div>

  3. In admin > CMS > Pages opened the page called home and in the Design tab in Custom Layout Update XML field I added this code: <block type="core/template" name="home_image-center" template="cms/home.phtml" /> between the reference tags.

I have put some text in the content of the static block, just to see whether it will be shown, but it's not. My final aim is to put that block there and make it available to have a static image or text in it, that can be changed at any time from the back-end.

26

I may be totally wrong, but you can call it like this

{{block type="cms/block" block_id="home_image-center"}} 

in cms -> homepage-> content : in that click show/hideeditor past above code it's work

  • 1
    I tried both your suggenstion and {{block type="cms/block" block_id="home_center_image" template="cms/content.phtml"}}... and it is not working. – Syspect Jun 26 '14 at 14:40
  • you are writing block and template both are not work you can call differently it will work like call template file {{block type="core/template" template="catalog/product/form-top.phtml"}}after call like block {{block type="cms/block" block_id="home_image-center"}} – Pawankumar Jun 26 '14 at 16:23
  • welcome kalpesh :) – Pawankumar Jun 28 '15 at 6:34
  • 6
    Starting with Magento Comunity 1.9.2.2 (or Enterprise Edition 1.14.2.2) you have to make sure that cms/block is allowed in System => Permissions => Blocks You can read more on dudesquare.nl/blog/2015/10/31/… – Stelian Dec 15 '15 at 10:48
  • 1
    This way works too if you add cms/block into System -> Permisions -> Blocks – Vasilii Burlacu Oct 3 '16 at 11:14
12

It is a late reply, but i will share. It is true that you can do it all from admin. You can add any static block to any cms page directly from admin as a widget. Open the CMS page and then click on content tab. At top click on Insert Widget... button. You will have the following window.

enter image description here

In the drop down, select CMS Static Block. Then you will have the following window.

enter image description here

Now, select any custom template, else keep it default and click on Select Block... button. In another pop up, you will have the complete list of hte blocks as below.

enter image description here

Select your desired block and the window will close. Now on insert widget window, click on insert widget, and the cms block will be added to your cms page.

It will insert the code, which will be like below:

{{widget type="cms/widget_block" template="cms/widget/static_block/default.phtml" block_id="46"}}

I am using this same way to add cms static blocks to my cms pages and it works fine.

Thank you

  • Works like a charm – Erdal G. Oct 22 '16 at 19:45
9

Right, so I (and you guys) were very close. In the current CMS page in Design > Custom design > Custom Layout Update XML field I had to put

<block type="cms/block" name="home_center-image" before="-">
      <action method="setBlockId"><block_id>home_center-image</block_id></action>
</block> 

and before I tried just <block type="core/template" name="home_image-center" template="cms/home.phtml" />.

Now it is working fine. :)

  • You can also add static block in content area like this : {{block type="cms/block" block_id="home_image-center"} – gelanivishal Mar 9 '17 at 7:05
4
 {{block type="cms/block" block_id="home_image-center"}}

http://www.magentocommerce.com/knowledge-base/entry/how-do-i-create-and-edit-static-blocks

0

You'll want to check out the following:

CMSPages

Then look for the line-item which has home as the value under URL Key - click the row to start editing it.

On your left-hand-side options menu, click the Contents tab, then click Show / Hide Editor to view the contents of the page in raw code.

You can edit the page from here & make the changes which you desire.

P.S. This is a bit of a tricky one seeing as the changes could - as you mentioned - be required to be made directly in the template file. But from my experience, this method usually works 100%.

  • I tried that one also. I even put just text, in the content, to test, but the text was not shown... That makes my think it is not the correct CMS page I am writing in. But I want to change the home page, and this is the only CMS page which has the word home in its name... – Syspect Jun 26 '14 at 14:07
  • Are you using a third party theme? – Moose Jun 27 '14 at 6:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.