How to display category custom design layout in product view page?

前端 未结 4 1475

Let\'s say I have two categegories, A and B.

I set A to use \'layout_a\' on Catalog -> Catalog Categories -> Click a category -> click custom design tab

I se

4条回答
  •  悲哀的现实
    2021-01-01 08:56

    Create an attribute with dropdown type and name attribute code 'which_category'. On the options tab fill in 'category_a' and 'category_b'

    Create two files in /app/design/frontend/default/YOURTEMP/template/catalog/product/

    lets say: view_cat_a.phtml and view_cat_b.phtml

    You can design your specific category product view page based on view.phtml.

    Change view.phtml to:

    helper('catalog/output'); 
    $_product = $this->getProduct();
        if ( $_product->getAttributeText('which_category') == category_a) {
            include('view_cat_a.phtml');
        } else {
            include('view_cat_b.phtml');
        }
    

    When you create a product you can choose the category on the attribute (define them in attribute_set)

提交回复
热议问题