Magento Sidebar Customization

谁说我不能喝 提交于 2019-12-11 12:38:49

问题


I have a magento website, of which Ive customized the rightside bar static block fine.

It displays as it should on all pages except the product pages.

Is this something that needs editing in the layout xml files, within the magento control panel or within other design files?

Thanks!

update:

The problem is that the global right sidebar is displaying everything as it should, however the product page is still displaying the old version, without the amends.


回答1:


You simply need to add the product view xml updates to your local.xml layout file (or create it). The file would be located at:

/app/design/frontend/your_package/your_theme/layout/local.xml

An abridged version of the xml you would need is:

<?xml version="1.0"?>
<layout version="0.1.0">

<!-- Layout Handle for Product View Page -->
<catalog_product_view>

    <!-- Reference Pointing to Right Sidebar -->
    <reference name="right">

        <!-- Enter All Right Sidebar Layout Updates Here -->

    </reference>

</catalog_product_view>

</layout>

If you renamed your right sidebar something else, change the reference name above to what you changed it to. Here's some quick references to show what you can do to arrange via local.xml:


Move or Remove Blocks

    <reference name="right">

        <!-- Removes Block By Name -->
        <remove name="name_of_removed_block"/>

        <!-- Insert Moved Block (Must Unset First, See Left Reference) -->
        <action method="insert">
            <blockName>name_of_unset_block</blockName>
            <siblingName>name_of_adjacent_block</siblingName>
            <after>1</after> <!-- 0 = Before / 1 = After Sibling Block -->
        </action>

    </reference>

    <reference name="left">

        <!-- Unset Block By Name, Can Be Inserted Elsewhere As Above -->
        <action method="unsetChild">
            <name>name_of_unset_block</name>
        </action>

    </reference>



Add A Block From a Template File

    <!-- Blocks Left and Right Automatically Load All Child Html -->
    <reference name="right">

        <!-- Load New Block From Template File -->
        <block type="core/template" name="new_block_name" template="page/html/newblock.phtml" after="adjacent_block_name" />

    </reference>

    <!-- Some Blocks (Like Header) Require Child Html to be Called After Set in XML -->
    <reference name="header">

        <!-- Adding a Block Below Won't Be Enough To Add Our Template File Here -->
        <block type="core/template" name="new_header_block" template="page/html/headerblock.phtml" />

    </reference>


Not all blocks added will show immediately, sometimes you need to go within the parent block's template file to add the child block where you would like. In the above example, I used the "header" block, for anything to actually be added I have to edit the .phtml file directly. (unless you have changed your header.phtml to only use $this->getChildHtml(''); as no block name indicates that Magento should load all child html blocks.)

In this case, we would have to make a change to header.phtml, and somewhere within that file (/app/design/frontend/your_package/your_theme/page/html/header.phtml) you would need to add:

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

Where you would like to see your block added to the header.

That should get you started in the right direction. Make sure that none of your pages/products/categories have any custom layout xml in their records on the backend that may be affecting what shows up on the front as well.



来源:https://stackoverflow.com/questions/18087800/magento-sidebar-customization

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!