2013-02-12 14 views
6

tôi có một liên kết làm việc được bổ sung vào top.links khối như thế này:Đi qua một lớp Helper một Parameter Thông qua một tập tin XML Layout

<block type="page/template_links" name="top.links" as="topLinks"> 
    <action method="addLink"> 
     <label>About Us</label> 
     <url helper="mymodule/getAboutUsUrl"/> 
     <title>About Us</title> 
     <prepare/> 
     <urlParams/> 
     <position>20</position> 
    </action> 
</block> 

Cuối cùng tôi muốn getAboutUsUrl biến thành getExternalSiteUrl. Tôi muốn có một hàm để lấy tham số. Ví dụ: getExternalSiteUrl ('about-us') mà sau đó sẽ trả về cái gì đó như/the/url/about-us. Tuy nhiên, tôi dường như không thể tìm cách gửi một tham số lớp trợ giúp trong tệp XML bố cục. Tôi đã tìm kiếm các mô-đun khác thực hiện việc này và không thể tìm thấy mô-đun trong mô-đun Khách hàng mà tôi đã tìm kiếm.

Có ai giúp được không?

Trả lời

7
<block type="page/template_links" name="top.links" as="topLinks"> 
    <action method="addLink"> 
     <label>About Us</label> 
     <url helper="mymodule/getAboutUsUrl"> 
      <arg>Now with more args!</arg> 
      <!-- will result in the string being passed as first arg --> 
     </url> 
     <title>About Us</title> 
     <prepare/> 
     <urlParams/> 
     <position>20</position> 
    </action> 
</block> 

Lưu ý rằng những người giúp đỡ không mở rộng Varien_Object, do đó phương pháp của bạn sẽ cần phải xác định một cách rõ ràng phương pháp getAboutUsUrl().