【问题标题】:Adding image in Magento via update layout通过更新布局在 Magento 中添加图像
【发布时间】:2013-11-20 01:15:26
【问题描述】:

我正在尝试使用管理区域的 cms ->page->design 部分中的布局更新,将图像等添加到 Magento 中带有左侧边栏页面的 2 列的左侧边栏部分.

是否可以从更新布局 xml 区域执行此操作?如果没有,你能解释一下如何创建一个模块(或其他任何需要的东西)。

谢谢。

【问题讨论】:

    标签: image layout magento sidebar


    【解决方案1】:

    如果您查看base/default/layout/catalog.xml,您将看到一个使用模板的示例,该模板带有可以在您的更新布局 XML 区域中指定的图像占位符:

        <reference name="left">
            <block type="core/template" name="left.permanent.callout" template="callouts/left_col.phtml">
                <action method="setImgSrc"><src>images/media/col_left_callout.jpg</src></action>
                <action method="setImgAlt" translate="alt" module="catalog"><alt>Our customer service is available 24/7. Call us at (555) 555-0123.</alt></action>
                <action method="setLinkUrl"><url>checkout/cart</url></action>
            </block>
        </reference>
    

    因此,在您的更新布局 XML 中,您可以编写如下内容:

        <reference name="left.permanent.callout">  <!-- match this to the block name from above -->
                <action method="setImgSrc"><src>images/media/my_file_name.jpg</src></action>
                <action method="setImgAlt" translate="alt" module="catalog"><alt>Some text here</alt></action>
                <action method="setLinkUrl"><url>your/path</url></action>
        </reference>
    

    您可以通过复制模板文件left_col.phtml 并根据需要进行更改来适应它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-02-08
      • 2014-08-29
      • 1970-01-01
      • 2014-08-23
      • 1970-01-01
      • 2013-04-07
      • 1970-01-01
      相关资源
      最近更新 更多