Magento Forum

   
Page 2 of 2
Custom Designs Per Category (or even product)
 
spleen - Artstore
Member
 
Avatar
Total Posts:  38
Joined:  2008-11-27
Berlin, Germany
 

I want a special Layout for my category with the ID 31, so

i placed the last line in the ProductController.php (app/code/core/Mage/Tag/controllers/)

class Mage_Tag_ProductController extends Mage_Core_Controller_Front_Action
{
    
public function listAction()
    
{
        $tagId 
$this->getRequest()->getParam('tagId');
        
$tag Mage::getModel('tag/tag')->load($tagId);

        if(!
$tag->getId()) {
            $this
->_redirectReferer();
            return;
        
}
        Mage
::register('current_tag'$tag);

        
$this->loadLayout();
        
$this->_initLayoutMessages('checkout/session');
        
$this->_initLayoutMessages('tag/session');
        
$this->renderLayout();
        
$update->addHandle('PRODUCT_CAT_'$product->getCatid());
    
}
}

and placed this somewhere in the catalog.xml (app/design/frontend/default/myTheme/layout/):

<PRODUCT_CAT_31>
           <
reference name="product.info">
               <
action method="setTemplate">
                 <
template>catalog/product/view_Querformat.phtml</template>
               </
action>
           </
reference>
    </
PRODUCT_CAT_31>

but it doesn’t work - nothing happens - the new phtml was not loaded!

I think it is just about the catalog.xml, WHERE (in wich section) do i have to place the code?

 
Magento Community Magento Community
Magento Community
Magento Community
 
monty617
Jr. Member
 
Total Posts:  11
Joined:  2008-04-18
 

I think perhaps people are misunderstanding how the Custom Layout Update currently works. The way they have it now you can just add things to the current layout here and not completely change to a new one. You can add things such as callouts and main content. I would check out your layout .xml files for references on things you can change.

_win: Your problem is that you are trying to add a full template over itself here and that is why you are getting double display.

<reference name="content">
            <
block type="catalog/product_view" name="product.info" template="catalog/product/view.phtml.1"></block>
</
reference>

I’ll give a quick example for adding a custom callout to a specific page or category.

Put this in your Custom Layout Update under the needed category or product:

<reference name="right">
<
block type="core/template" name="right.permanent.callout" template="callouts/mycustomcallout.phtml"/>
</
reference>

Then create a mycustomcallout.phtml file and add whatever content you want. You could even call a CMS static block in your .phtml template to be able to edit the callout from the backend.

You can do this for things other than callouts (again reference xml files for examples), but I find that this is one of the best ways to add quick info to a specific product or category.

You can completely change templates as well but not through the Custom Layout Update option as it stands now. You have to hard code as in fenixf‘s example. It seems to me that you should actually be able to accomplish this by doing something of this manner:

<reference name="root">
            <
action method="setTemplate"><template>page/customtemplate.phtml</template></action>
        </
reference>

... or something similar, but I have not been able to get it to work fully through the Custom Layout Update option.

Hopefully they will come up with a better way of managing custom templates in future releases.

 
Magento Community Magento Community
Magento Community
Magento Community
 
brendanb
Mentor
 
Total Posts:  1077
Joined:  2008-07-16
London, United Kingdom
 

great post i managed to get this to work for a particular product. But as said above, it would be nice to have the ability to switch to an alternative template.

cheers

 
Magento Community Magento Community
Magento Community
Magento Community
 
VortexCommerce
Sr. Member
 
Avatar
Total Posts:  104
Joined:  2008-08-06
Harrogate, UK
 

Thanks fenixf, was very useful!

 
Magento Community Magento Community
Magento Community
Magento Community
 
scjunkies
Member
 
Total Posts:  55
Joined:  2008-09-03
Houston, Texas, USA
 

You can make your own template for a particular product by making a new version of the view.phtml file and placing it in the following directory.  You can probably place it in a “local” instead of the “base” folder but i did not try that.

app/design/frontend/base/default/template/catalog/product/NEW_VIEW.phtml

After that, go to the product that you want to use the new template and on the “Custom Layout Update” place the following code.

<reference name="product.info">
<
action method="setTemplate"> <template>catalog/product/NEW_VIEW.phtml</template></action>
</
reference>

I’m using Magento ver. 1.4.1.1 & 1.4.2.0 .... I have not tested this method on other versions.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Cajetan
Jr. Member
 
Total Posts:  28
Joined:  2008-11-15
 

Does work with version 1.3.2.4 as well!

Thanks a lot to all contributing people!

Regards,
cajetan

 
Magento Community Magento Community
Magento Community
Magento Community
 
mmabardy
Member
 
Total Posts:  67
Joined:  2010-07-09
 

I know this is an old thread but hopefully some of you are still out there.  I am trying to add a custom cms block to my categories through custom layout update.  I want the cms block (which will be text, maybe and image, but mostly text) to appear in the left side bar, preferrable at the top before my layered navigation ( I am calling 2columnsleft.phtml from the category page layout drop down).  I will create mulitple cms blocks so that I can call different ones for different categories.  It seems like it should be fairly simple to do from the backend and I have read that I can do this, but it is not working.

In my category, under custom layout update, I have pasted this code:

<reference name="left">
    <
block type="cms/block" name="womleftbartex" before="-">
         <
action method="setBlockId"><block_id>womleftbartex</block_id></action>
    </
block>
</
reference>

It is not working.  Maybe I have the value for name incorrect.  My values for the CMS block that i created are
block title: womleftbartext
block identifier: womleftbartext

EDIT

Oh boy, I got it to work!  I had my name and blockid spelled incorreclty.  Works like a charm. 

I gave them the same value because I am unclear as to how they are referenced in the code.

Are there any template files that I need to edit? 

Any help that you can provide so that I can get this working would be great! Thank you!

 
Magento Community Magento Community
Magento Community
Magento Community
 
loeffel
Guru
 
Avatar
Total Posts:  427
Joined:  2009-02-03
 

Isn’t there a way to set a custom skin only? I don’t want to create complete themes as all layout changes I require can be done via css. So my custom theme should be used but I need to be able to set different skins for each category.

 
Magento Community Magento Community
Magento Community
Magento Community
 
brendanb
Mentor
 
Total Posts:  1077
Joined:  2008-07-16
London, United Kingdom
 

Yep it can be done.

Basically I wanted a specific category to have a slightly different look & feel. This was just css changes and some image differences.

What I did was goto the category in question. Select the custom design tab

in the custom layout update add in the following code

<reference name="head">
    <
action method="addCss">
        <
stylesheet>css/styles_pink.css</stylesheet>
        <
params>media="all"</params>
    </
action>
</
reference>

What this above does is replaces the existing css file with the modified version for this category only

brendan

 
Magento Community Magento Community
Magento Community
Magento Community
 
DFS
Jr. Member
 
Total Posts:  25
Joined:  2011-01-03
 

Thank you just what I needed…

 
Magento Community Magento Community
Magento Community
Magento Community
 
Greg Demetrick
Member
 
Avatar
Total Posts:  64
Joined:  2009-03-31
Burlington, VT
 
scjunkies - 28 October 2010 11:16 AM

You can make your own template for a particular product by making a new version of the view.phtml file and placing it in the following directory.  You can probably place it in a “local” instead of the “base” folder but i did not try that.

app/design/frontend/base/default/template/catalog/product/NEW_VIEW.phtml

After that, go to the product that you want to use the new template and on the “Custom Layout Update” place the following code.


<reference name="product.info">
<
action method="setTemplate"> <template>catalog/product/NEW_VIEW.phtml</template></action>
</
reference>

I’m using Magento ver. 1.4.1.1 & 1.4.2.0 .... I have not tested this method on other versions.

This works perfectly at the Product level but lets say I wanted to apply this change to every product under a specific category? i.e. I have 1000 products under Category XYZ. I don’t want to filter the 1000 products and do a mass update because it might over-ride the existing custom design paramaters I have in those products. Is there a way I can apply this XML to the Category and have it affect the products in the category? Custom Design Updates in the Category setup seems to only affect the category pages and not the products in the category.

UPDATE: I stumbled into the way to do this without modifying code. Under the Category configuration, if you set “Apply To Products” to Yes then the Custom Layout Update is floated into all products in the category.

 
Magento Community Magento Community
Magento Community
Magento Community
 
tmp2000
Jr. Member
 
Total Posts:  9
Joined:  2011-07-14
 

I tried to modify the layout display in “Custom Design” of one category ,such as “A”.It is ok if visit from A, then visit productA1.The layout is just right.But if you direct visit from the product url,then it will show the default theme layout .
I know it can be done by changing Custom Design under every product.But I think it is too large work.
Does any one solve this problem or any other solution for this?
I just want to let different categories’ product show different image size and page layout.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top
Page 2 of 2