Add links Magento

Share
Posted on September 6th, 2011 | Posted by admin

Creating a link in magento is not that obvious if you never did before.

Today we’re going to see how to add them to a Static Block or a Page (under your CMS panel).

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(); ?>

Magento: Display Static Block via Custom Layout Update

Share
Posted on April 21st, 2011 | Posted by admin

We were needing to display a static block in the left column (of the 2-columns-left template). We only needed to display it for a few specific products though. There are a couple ways you can do it via Custom Layout Updates. In our case, the products were all in a specific category, and we wanted the static block to show up on the list view AND the product view. So, we put this code in on the product level and the category level:

<reference name="left">
    <block type="cms/block" name="static_block_identifier" before="-">
        <action method="setBlockId"><block_id>static_block_identifier</block_id></action>
    </block>
</reference>
Page 1 of 212»