I have problem with inserting custom block/template into cms page editor. If I put the below code to header.phtml it works fine and it displays content inside home page:
echo $this->getLayout()->createBlock('company_slider/slider')->setTemplate('company/slider/slider.phtml')->toHtml();
But if I try to insert this into cms page it won't display anything:
{{block type="company_slider/slider" name="slider_slider" template="company/slider/slider.phtml"}}
I have these lines in extension config file:
<global>
<blocks>
<company_slider>
<class>Company_Slider_Block</class>
</company_slider>
</blocks>
</global>
Am I missing anything? I guess paths are correct because it works if I insert block directly to phtml file as shown above.
1 Answer 1
have you added the block in white list?
- Login to admin panel then go to System> Permissions> Blocks
- Add the block - Enter company_slider/slider
- in the field Set Allowed to Yes
-
I added company/slider_slider but no difference.JohnyFree– JohnyFree2016年01月27日 12:58:25 +00:00Commented Jan 27, 2016 at 12:58
-
you mean company_slider/slider right?Patrick Knudsen– Patrick Knudsen2016年01月27日 13:12:30 +00:00Commented Jan 27, 2016 at 13:12
-
yes, my mistake. I added company_slider/sliderJohnyFree– JohnyFree2016年01月27日 13:13:45 +00:00Commented Jan 27, 2016 at 13:13
-
I just realized that actually solved the problem, I am not sure why it didn't work immediately when I added block into permissions, but it is indeed that what it solved the problem. Thank you! I will whitelist my block inside installation script (instructions here)JohnyFree– JohnyFree2016年01月27日 13:47:56 +00:00Commented Jan 27, 2016 at 13:47
{{block type="core/template" name="slider_slider" template="company/slider/slider.phtml"}}