Magento边栏自定义 [英] Magento Sidebar Customization

查看:89
本文介绍了Magento边栏自定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个magento网站,我已经为其自定义了右侧栏静态块.

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.

这是需要在布局xml文件中,在magento控制面板中还是在其他设计文件中进行编辑的东西?

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

谢谢!

更新:

问题在于全局右侧栏按原样显示所有内容,但是产品页面仍显示旧版本,而没有修改.

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.

推荐答案

您只需要将产品视图xml更新添加到local.xml布局文件中(或创建它).该文件位于:

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

您需要的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>

如果您将右侧边栏重命名为其他名称,请将上面的引用名称更改为更改后的名称.以下是一些快速参考资料,显示了您可以通过local.xml进行的操作:


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:


    <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>





    <!-- 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>


并非所有添加的块都会立即显示,有时您需要进入父块的模板文件以在所需的位置添加子块.在上面的示例中,我使用了"header"块,实际上要添加的任何内容都必须直接编辑.phtml文件. (除非您已将header.phtml更改为仅使用$ this-> getChildHtml('');因为没有块名指示Magento应该加载所有子html块.)


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.)

在这种情况下,我们必须对header.phtml进行更改,然后在该文件中的某个位置(/app/design/frontend/your_package/your_theme/page/html/header.phtml)中添加以下内容:

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'); ?>

您希望在其中看到您的块添加到标题的位置.

那应该使您朝正确的方向开始.确保您的页面/产品/类别在后端的记录中都没有任何自定义布局xml,这也可能会影响前端显示的内容.

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.

这篇关于Magento边栏自定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆