Changing currency selection position in Magento

The currency selector is currently at the top of my development site:

http://nordschleife.metaforix.net/118/118/index.php/kyocera.html

However, I would like to toggle the currency switch just under the "Price" heading of the table.

I tried

echo $this->getCurrency();

      

but there is nothing. I guess I need some kind of method like getCurrencyHtml()

, but it seems like there is no such method.

Or do I need to edit my layout files and how do I do that?

+1


a source to share


1 answer


I can show you a way to do this, but in order to understand what's going on, you need to have at least a basic understanding of how Magento layout files work. To do this, you should read the design guide here and a basic explanation of how it all works.

Now there are several ways to handle this, but I think the easiest way is to just use an existing currency block. Seeing how you put it in that little cell, I'm assuming you don't need the heading "Choose your currency". Therefore, we need a new template.

A block in Magento consists of two files, a block class that does all the work of creating dynamic content and a template file that uses block class methods along with some html to create the final result. The hard cancellation of fetching currency parameters is already done by the block class, so if we can use this in tandem with a new template file we'll be installed.

Existing declaration in layout files and in particular directory.xml

<block type="directory/currency" name="currency" before="catalog.leftnav" template="directory/currency.phtml"/>

      

So the template file is app \ design \ frontend [frontend] [theme] \ template \ directory \ currency.phtml

Copy it to currency2.phtml and remove the header.

Now, to create a new block named "currency2" consisting of the old block class and the new template file, we write



<block type="directory/currency" name="currency2" as="currency2" template="directory/currency2.phtml"/>

      

We will use this in /template/catalog/product/list.phtml, so open catalog.xml and place the new block declaration in

<block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">

      

in the appropriate section (I'm assuming catalog_category_default).

Finally open /template/catalog/product/list.phtml and add

<?php echo $this->getChildHtml('currency2'); ?>

      

where you want the block to be displayed.

+5


a source







All Articles