27

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.

asked Jun 26, 2014 at 14:01

6 Answers 6

28

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

Julian
3731 gold badge4 silver badges16 bronze badges
answered Jun 26, 2014 at 14:11
5
  • 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. Commented Jun 26, 2014 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"}} Commented Jun 26, 2014 at 16:23
  • welcome kalpesh :) Commented Jun 28, 2015 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/… Commented Dec 15, 2015 at 10:48
  • 1
    This way works too if you add cms/block into System -> Permisions -> Blocks Commented Oct 3, 2016 at 11:14
13

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

answered Mar 1, 2016 at 7:38
1
  • Works like a charm Commented Oct 22, 2016 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. :)

answered Jun 26, 2014 at 15:32
1
  • You can also add static block in content area like this : {{block type="cms/block" block_id="home_image-center"} Commented Mar 9, 2017 at 7:05
4
Murtuza Zabuawala
14.8k10 gold badges47 silver badges76 bronze badges
answered Jun 26, 2014 at 14:15
2

you can add static cms block in home page in following way :

 adding static cms block in magento 1.x :
 {{block type="cms/block" block_id="identifier_of_your_block"}}
 adding static cms block in magento 2.x :
 {{block class="Magento\Cms\Block\Block" block_id="identifier_of_your_block"}}

hope this helps!

answered Jan 10, 2020 at 9:10
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%.

answered Jun 26, 2014 at 14:04
2
  • 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... Commented Jun 26, 2014 at 14:07
  • Are you using a third party theme? Commented Jun 27, 2014 at 6:15

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.