Magento Themes and Magento Extensions

How to customize Magento to use a different page template when the cart is empty

Posted on December 31st, 2012 | Posted by admin

Being between projects at the moment and having a bit of beach time on my hands Magento question asked on twitter. So, here’s how to use a different template file when the cart is empty.

First, you’ll have to create a custom Magento extension (if you don’t know how to do that, now is the time to stop reading further and go through some of the Magento documentation and tutorials available). You will only need the etc, controllers and Model directories for this custom extension. As always there are multiple ways to skin a cat, so I will start with the first method:

1. Override the checkout controller’s index action and update the layout

Add the following code to your custom controller class before the call to the renderLayout method

Insert dynamic links into Magento wysiwyg editor to set store id

Posted on December 29th, 2012 | Posted by admin

Linking to other cms pages from Magento‘s wysiwyg editor is simple, but if you don’t know how to do it, you will get a few suprises.
The correct way to create a link is to wrap the url into a magento handler like this:

<a href=”{{store url=’cms-page-url’}}”>CMS Page Title</a>

To link directly to the front page, simply leave the url empty.

<a href=”{{store url=”}}”>Front Page</a>

Magento – Re-ordering Block items

Posted on December 27th, 2012 | Posted by admin

Magento has lots of blocks that display in the left and right columns (based on your layout). Changing the order in which they are displayed or sorted is easy. Navigate to the folder “app\design\frontend\default\YOUR_THEME\layout”. In this folder, there are several XML files which are called Layouts.
Magento Layouts are the tools with which you can assign content blocks to each structural block you create. Layout exists in the form of XML text-file and by modifying the layout you are able to move blocks around in a page and assign templates to the content blocks to produce markup for the structural blocks.

To change the order, find a block you want to change. So if I wanted to display the products compared side box first in my left column, I would do by adding before=”-” as an attirbute to it’s xml node. Now, save it and upload. That’s it!

All About Prototype’s Selector Functions

Posted on December 26th, 2012 | Posted by admin

the humble dollar sign. In Prototype, the dollar sign is the king. If you’re tired of typing out hundreds ofdocument.getElementById() statements, or if you’re developing for Magento – which uses Prototype as its Javascript library – then you’ll need to be familiar with this function, the function that the whole of the rest of Prototype is based on.

OK, so I’ll admit, there are a few useful dollar sign functions. The first is just the single dollar sign, which is essentially an alias for the previously mentioned document.getElementById() function. However, it does have a few benefits – quite aside from its much shorter name.

Firstly, the obvious. These two statements are equivalent:

document.getElementById('nav'); // gets the element with an ID of 'nav'
$('nav'); // also gets the element with an ID of 'nav'

Creating Block from controller in Magento

Posted on December 25th, 2012 | Posted by admin

There are two types of blocks can be created in Magento

a) Structural Block: This block usually contains the attribute ‘as’ with block tag through which the application will communicate with designated area.

b) Content Block: These are the blocks that produces actual content inside each structural block. It seems like normal template file that are used to show particular data on the page.

Most of the time a programmer needs to create a structural block and need to show it into the content area of the page. Here are the code you need to write for it.

Page 1 of 612345»...Last »