In Magento, Display Static Block in Home page using CMS Page

Share
Posted on March 23rd, 2013 | Posted by admin

In Magento, one off easiest way to show different static blocks in Home page using CMS page. For this first login into admin side and create the necessary static blocks to be display in frontend. To create static block goto CMS->Static Blocks.

Click Add New Block button and fill the required fields and finally save it. Just note down the static block Identifier that need to be use in below code to display block in Home pages.

Then goto CMS-> Pages, check the column URL key as “home” and click on it. In left hand side, click the content tab and place the below code in editor and do the alignment as per your design needs.

{{block type="cms/block" block_id="your_cms_block_identifier"}}

Creating and Showing a static block in Magento Frontend

Share
Posted on March 21st, 2013 | Posted by admin

Static block is the great way to show up different types of data in your Magento webstore. This is the easiest way to display something on the frontend of your magento website.  The content of the blocks are created and modified from Magento Admin panel which can be placed on one or multiple pages. To create a static block you can follow some simple steps which are given bellow.

Creating a Static Block:

A. Go to the Magento Admin panel and then select the  CMS -> Static Blocks.

B. Then Click on the “Add New Block” button from the right top .

C. Now fillup the following fields:

How to use category to show static pages

Share
Posted on August 3rd, 2011 | Posted by admin

Some days ago, I worked on a project which has many URLs linked to static content page. These URLs are shown in main menu. As you know, in main menu are categories. Normally, almost developers add these URLs directly to the phtml file. But I will show you how to do it by another way which is using category ;)
Therefore, you can use each category for one static content page.
First of all, create a static block (instead of static page) by going to CMS > Static Blocks.
After that, going to Catalog > Manage Categories to add new category. To make the category show static block, navigate to ‘Display settings’ tab and select ‘Static block only’ in display mode drop down field.

Show a static block in html

Share
Posted on July 7th, 2011 | Posted by admin

In one of my previous posts, I wrote about how to show a block in a .phtml file but some people asked me about the static block. So here is the solution:
Please put this piece of code into a correct place of the .phtml file that you want to show a static block.

<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('my-new-block')->toHtml() ?>

How to call a block directly from a .phtml file?

Share
Posted on July 7th, 2011 | Posted by admin

Sometimes you want to call a block inside a .phtml file without defining in layout. In this case, we can use a method called toHtml of a block.

Assume that we have a block called Mymodule and a template that is located at: mymodule/myblog.phtml

So to generate that block we use:

<?php echo $this->getLayout()->createBlock('mymodule/myblock')->setTemplate('mymodule/myblock.phtml')->toHtml(); ?>

Page 1 of 212»