如何在magento处包裹左侧导航块

时间:2014-06-24 10:40:51

标签: magento

我遇到了很难将左侧导航块包装到我自己的DIV容器中

在layout / customer.xml

看起来像是

<reference name="left">
            <block type="customer/account_navigation" name="customer_account_navigation" before="-" template="customer/account/navigation.phtml">
                <action method="addLink" translate="label" module="customer"><name>account</name><path>customer/account/</path><label>Account Dashboard</label></action>
                <action method="addLink" translate="label" module="customer"><name>account_edit</name><path>customer/account/edit/</path><label>Account Information</label></action>
                <action method="addLink" translate="label" module="customer"><name>address_book</name><path>customer/address/</path><label>Address Book</label></action>
            </block>
            <block type="checkout/cart_sidebar" name="cart_sidebar" template="checkout/cart/sidebar.phtml">
                <action method="addItemRender"><type>simple</type><block>checkout/cart_item_renderer</block><template>checkout/cart/sidebar/default.phtml</template></action>
                <action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>checkout/cart/sidebar/default.phtml</template></action>
                <action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>checkout/cart/sidebar/default.phtml</template></action>
            </block>
            <block type="catalog/product_compare_sidebar" name="catalog.compare.sidebar" template="catalog/product/compare/sidebar.phtml"/>
            <remove name="tags_popular"/>
        </reference>

所以左侧块正在从下一个模板组装

customer/account/navigation.phtml
checkout/cart/sidebar.phtml
catalog/product/compare/sidebar.phtml

如何将它们包装到我的包装器中,如

  <div class="mywrapper">
// ... all content from templates
  </div>

????

我不想在第一个模板中添加开放包装器,并将最后一个包装器添加到最后一个

我可以在layout / customer.xml中添加它吗?

提前致谢

1 个答案:

答案 0 :(得分:0)

您可以在相应的页面模板中添加,而不是通过XML添加 - 正如您所指出的那样,您将永远不会这样做,并且将被迫首先包含开始标记的块和最后包含结束标记的块。

因此,如果打开template/page/2columns-left.phtml(或3columns.phtml也会有左侧边栏),那么请在那里添加我们的标记;

    <div class="main-container col2-left-layout">
        <div class="main">
            <?php echo $this->getChildHtml('breadcrumbs') ?>
            <div class="col-main">
                <?php echo $this->getChildHtml('global_messages') ?>
                <?php echo $this->getChildHtml('content') ?>
            </div>
            <div class="col-left sidebar">
               <div class"yourDivHere">
                  <?php echo $this->getChildHtml('left') ?>
               </div>
            </div>
        </div>
    </div>