html - Magento,如何在 block 中添加静态 url 链接

标签 html css xml magento

我坚持以编程方式在 block 中添加 url 链接,我需要将 URL 添加到在 CMS/page 下编辑的自定义页面,我想通过添加如下所示的内容将其添加到 .xml 文件中。

<action method="addLink" 
        translate="label title" 
        module="catalog">
        <label>My Account</label>
        <url helper="customer/getAccountUrl" />
        <title>My Account</title>
</action>

上面的示例从模块中检索 url,但不知道静态 CMS/页面 url 应该使用哪些参数。请帮帮我。

最佳答案

让我以 top.links block 为例来解释这一点。

<block type="page/template_links" name="top.links" as="topLinks"/>

“addLink”函数在 Mage_Page_Block_Template_Links 中定义。函数的定义是

public function addLink($label, $url='', $title='', $prepare=false, $urlParams=array(),
        $position=null, $liParams=null, $aParams=null, $beforeText='', $afterText='')

此外,编写 html 代码的 phtml 文件是“page/template/links.phtml”。

<reference name="top.links">
     <block type="wishlist/links" name="wishlist_link">
         <action method="addWishlistLink"></action>
     </block>
 </reference>

你的问题的答案很简单。

假设我们需要向顶部链接添加一个新链接,比如说一个名为 Terms and Conditions 的 CMS 页面的链接。为此,打开一个布局文件,假设是 customer.xml 并添加以下代码:

<default>
<reference name="top.links">
  <action method="addLink" translate="label title">
    <label>Terms and Condition</label>
    <url>terms</url>
    <title>Terms and Condition</title>
    <prepare>true</prepare>
    <position>2</position>
  </action>
</reference>
</default>

关于html - Magento,如何在 block 中添加静态 url 链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27126323/

相关文章:

javascript - 使用 AngularJS 动态更新 CSS 样式

html - 强制 DIV 在所有边上具有相同的边距

c# - XmlReader 异常处理 - IEnumerable

python - 使用 ElementTree 从文件夹中读取多个 xml 文件

java - 在android TextView中格式化长段落

php - 如何根据用户点击 Jquery Galleria 幻灯片在开始时设置自定义图像

css - 需要帮助使用 css 设计页面

javascript - 根据单击的元素滚动到页面上的相同位置

html - 单击链接中的复选框会导致指向后续链接——如何避免这种情况?

php - 如何使一个div动态地与另一个div一起移动