tags:

views:

155

answers:

3

I'm using this extension in my Magento store: http://www.magentocommerce.com/extension/reviews/module/608/p/2/

I use this block to call the extension on page A: {{block type="mostviewed/list" name="home.mostviewed1.list" alias="product_homepage" template="catalog/product/top_10_full.phtml" }}

I would also like to call a modified version of this block and place it on page B. How do I do this. If I modify the code then it changes it for both Page A and B. How can I have slightly different versions of the same extension. I thought about copying it but I don't know what to change in order to be able to call the copied version with a different block name.

Or is it possible to send a parameter back when calling the extension. For example this is the piece of code from the extension that will need to differ on each page:

$storeId = Mage::app()->getStore()->getStoreId();
$category   = Mage::getModel('catalog/category')->load('10');  //THIS IS THE CATEGORY ID TO DISPLAY - PUT CAT ID IN HERE
$this->setStoreId($storeId);

On page A the CategoryID should be 10 and on Page B it should be 11.

Thanks!

A: 

I think for that modified version you will have same name of page i. e. top_10_full.phtml so copy the contents of that file and make another file with different name and call that file in Page B.

I dont know this will be useful for you. if not useful, ignore it.

Pranjali
The problem is Page B needs to use a modified version of the extenion. Doing this would result in both pages using the same extension.
a1anm
A: 

If the piece of code you posted is in fact in a phtml file you can make a copy of it and call it top_10_full_B.phtml for example. Then change the category ID in the new file to 11 and on page B you can then call this block by using. {{block type="mostviewed/list" name="home.mostviewed2.list" alias="product_homepage_B" template="catalog/product/top_10_full_B.phtml" }}. Name and alias are changed to keep them unique, normally speaking not strictly needed but still a good thing to do to avoid conflicts. And of course the template called has been changed to use the new one.

Haven't taken a look at the extension but this should work as far as I can tell from your post.

Frederico
The code I posted isn't from a phtml file. It's from a php file with the path of app/code/local/Luxe/MostViewed/Block/List.php
a1anm
A: 

You can add a parameter to the call to the block.
For example:

{{ block type="mostviewed/list" name="home.mostviewed2.list" alias="product_homepage_B" template="catalog/product/top_10_full_B.phtml" cat="10" }}

You can then get that parameter in the template with

$categoryID = $this->getCat();

Then, when you load the category, use

$category   = Mage::getModel('catalog/category')->load($categoryID);

One Caveat - I've used this method in the block code. My reason tells me that it should work in the template code as well. If it doesn't, that's the first place I would look.

Hope this helps.

Laizer
worked perfectly!! thanks!
a1anm