<file> tag in layout file.

I have use one third party extension. In their layout file they have use the below code.

<action method="addJs">
     <file helper="rewardssocial/purchase_share/getJs" />

I don't know what the purpose of the file tag in that.

1 Answer 1


Lets start from <action method="addJs">.

This is the same as calling


But if you take a look at methods signature, you will see that it has two parameters.

public function addJs($name, $params = "")

That means that content of tags

 <file helper="rewardssocial/purchase_share/getJs" />

will be passed as $name and $params values. Name of tags here means nothing.

Order is only important.

<file> tag has no content. But has helper attribute, which tells that the result of helper method execution will be passed as first attribute value.

So as a result this xml is equal to.


Also you can specify parameters which can be passed to your helper

<file helper="rewardssocial/purchase_share/getJs">
    <arg>Now with arg!</arg>
    <!-- more args here -->

This is equal to

Mage::helper('rewardssocial/purchase_share')->getJs('Now with arg!')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.