モジュールのバックエンド設定の属性(「yes / no」)が「yes」に設定されている場合にのみ、カスタムJSファイルをモジュールに追加したいと思います。
これまで、モジュールconfig.xmlでlayout.xmlファイルを次のように参照してきました。
<frontend>
<layout>
<updates>
<modulename>
<file>modulename.xml</file>
</modulename>
</updates>
</layout>
</frontend>
layout.xmlは、期待どおりに.jsファイルをロードします。可能であれば、system.xmlファイルと同様の依存関係を追加したいと思います。
<sortby translate="label">
<label>Sort by:</label>
<frontend_type>select</frontend_type>
<sort_order>40</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<source_model>path/to_settings</source_model>
<depends><sortby>1</sortby></depends>
</sortby>
とにかく、バックエンド設定フィールドの値に応じてカスタムJSファイルをロードするにはどうすればよいですか?
次のように追加できます:
<reference name="head">
<block ifconfig="path_to_setting" type="your_block_type" name="some_name">
<action method="addJs"><script>path_of_file.js</script></action>
</block>
</reference>
物事をあなたの価値観に置き換えてください
ifconfig属性値がtrueの場合、JSファイルがロードされます。
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加