How to category and store language based side columns

Last modified by elbie on Thu, June 24, 2010 17:05
Source|Old Revisions  

This is an old revision of the document!


How to get category and store language based side columns

In case you would like to create category based lift/right side columns for each of the languages of your website, here is a potential timesaver :-)

I use it to have product (service) appealing landing pages for Adwords

Step 1:

Open this file: /app/design/frontend/default/yourskin/layout/catalog.xml

Where is says this:

<reference name=”left”> <block type=”core/template” name=”left.permanent.callout” template=”callouts/left_col.phtml”> <action method=”setImgSrc”><src>images/media/col_left_callout.jpg</src></action> <action method=”setImgAlt” translate=”alt” module=”catalog”><alt>Our customer service is available 24/7. Call us at (800) DEMO-NUMBER.</alt></action> <action method=”setLinkUrl”><url>checkout/cart</url></action> </block> </reference>

Add the following (replace, copy above, copy below depending your requirements)

<reference name=”left”> <block type=”catalog/navigation” name=”catalog.navigation” template=”catalog/catagory/custom_left_sidecolumn.phtml”/> </reference>

Step 2:

As you can imagine, you now nned to create a file called: custom_left_sidecolumn.phtml at this location: app/design/frontend/default/yourskin/yourtemplate/catalog/category

In that file you copy/paste the following:

<?php $category=$this→getCurrentCategory()→getName()?> <?php $lang = Mage::app()→getStore()→getCode(); ?> <?php echo $this→getLayout()→createBlock(’cms/block’)→setBlockId(’left_’.$category.’_’.$lang)→toHtml(); ?>

Step 3:

Create the static blocks for each of the categories that you would like a custom block to appear. Example block names: left_categoryA_storecode1 left_categoryB_storecode1 left_categoryA_storecode2 left_categoryB_storecode2 left_categoryC_storecode2 etc...

Additional info: The blocks will only show up if you have the block created with the correct id. If you have language selectin with links, hover over the links to pickup the storecode is the easiest, otherwise have a look into: System/Manage Stores > Edit Store View > Code

If you now think that the left column is really empty due to missing call outs you can add the following to the catalog.xml in order to have a more generic left/right column. You can create several static blocks with the same identifier and activate them each only in the required language. Here is the code to add:

<reference name=”left”> <block type=”cms/block” name=”left_column_block_QM_fr”> <action method=”setBlockId”><block_id>left_column_block</block_id></action> </block> </reference>

Enjoy!




 

Magento 2 GitHub Repository

Magento Job Board - Some sort of tag line goes here

Latest Posts| View all Jobs