[[CS-Cartめも]] Cs-Cartでカスタマイズを行いたい場合は、コアファイルは改変せずにアドオンをインストールすることで対応します。~ コアファイルは app/functions/ 以下に配置されています。 app/addons/ 以下にアドオンごとにフォルダ分けして配置し、管理画面からインストールを行います。 *ディレクトリ構造 [#mfe4087d] -app/addons/<add-on name> --addon.xml … メインデータ(必須) --func.php … 関数類(必須) --init.php … フックポイントリスト(必須) --config.php … 設定データ --controllers … 独自コントローラーや「pre- / post- コントローラー」類 --schemas … 標準スキーマを拡張するファイル --controllers/ … 独自コントローラーや「pre- / post- コントローラー」類 --schemas/ … 標準スキーマを拡張するファイル類 -js/addons/<add-on name> … js類 -design/backend/templates/addons/<add-on name> … 管理パネルテンプレート類 -var/themes_repository/basic/templates/addons/<add-on name> … フロントテンプレート類 -var/themes_repository/basic/mail/templates/addons/<add-on name> … メールテンプレート類 -js/addons/<add-on name>/ … js類 -design/backend/templates/addons/<add-on name>/ … 管理パネルテンプレート類 -var/themes_repository/basic/templates/addons/<add-on name>/ … フロントテンプレート類 -var/themes_repository/basic/mail/templates/addons/<add-on name>/ … メールテンプレート類 -var/langs/ja/addons/<add-on name>.po … 言語ファイル アドオンを配布する場合は上記の構成でzip, tgz, gzのいずれかの形式で圧縮します。 *フックポイント [#ta815541] Cs-CartではPHPコード内で用意されている''PHPフック''と、Smarty内で用意されている''テンプレートフック''の2種類のフックポイントがあります。 自身でアドオンを作成する場合は、これらのフックポイントをフックすることでカスタマイズを入れて行くことになります。 フックポイントは[[Hooks base:http://www.cs-cart.com/api]]で検索することができます。~ *Pre- and Post- コントローラー [#g7fc19f1] PHPフック以外にも標準のコントローラーの前後でそれぞれ処理を追加することができます。 products.php コントローラーであれば、products.pre.php で前に実行され、products.post.php で後に実行されます。 *テンプレートの上書き [#g2cedab2] テンプレートフックを使用せずに標準のテンプレートをオーバーライドして完全に上書きすることも可能です。 design/backend/templates/views/index/index.tpl をオーバーライドする場合は、overrides ディレクトリを作成し、以下のファイルを設置します。~ design/backend/templates/addons/[アドオン識別子]/overrides/views/index/index.tpl *設定ファイル [#w651df12] アドオンには必ず設定ファイルが必要になります。~ hello_worldアドオンを作成する場合は、以下に addon.xmlファイルを作成します。 app/addons/hello_world/addon.xml <?xml version="1.0"?> <addon scheme="3.0"> <id>hello_world</id> <version>1.0</version> <priority>100500</priority> <settings edition_type="ROOT,ULT:VENDOR"> <sections> <section id="general"> <items> <item id="some_prop"> <type>input</type> <default_value>Hello World!</default_value> </item> <item id="some_dropdown"> <type>selectbox</type> <default_value>blue</default_value> <variants> <item id="red"></item> <item id="green"></item> <item id="blue"></item> </variants> </item> </items> </section> </sections> </settings> <position>0</position> <status>active</status> <default_language>en</default_language> <auto_install>MULTIVENDOR,ULTIMATE</auto_install> </addon> フォルダ名とidは一致させる必要があります。 これだけで管理画面から アドオン - アドオンの管理 - 利用可能なすべてのアドオンを表示 にて作成したアドオンのインストールが可能になります。 *言語ファイル [#jfe272b9] 多言語対応のため、gettextによるpoファイルで管理されています。 英語の場合は /var/langs/en/addons/hello_world.po~ 日本語の場合は /var/langs/ja/addons/hello_world.po~ にそれぞれ配置することになります。 設定ファイルとは別の場所になるので要注意です。~ アドオンごとに同一フォルダにまとめられないのが気持ち悪い… var/langs/en/addons/hello_world.po msgid "" msgstr "Project-Id-Version: tygh" "Content-Type: text/plain; charset=UTF-8\n" "Language-Team: English\n" "Language: en_US\n" msgctxt "Addons::name::hello_world" msgid "Hello World" msgstr "Hello World" msgctxt "Addons::description::hello_world" msgid "Say hello to the world." msgstr "Say hello to the world." msgctxt "SettingsOptions::hello_world::some_prop" msgid "Some Prop" msgstr "Some Prop" msgctxt "SettingsOptions::hello_world::some_dropdown" msgid "Some Dropdown" msgstr "Some Dropdown" msgctxt "SettingsVariants::hello_world::some_dropdown::red" msgid "Red" msgstr "Red" msgctxt "SettingsVariants::hello_world::some_dropdown::green" msgid "Green" msgstr "Green" msgctxt "SettingsVariants::hello_world::some_dropdown::blue" msgid "Blue" msgstr "Blue" var/langs/ja/addons/hello_world.po msgid "" msgstr "Project-Id-Version: tygh" "Content-Type: text/plain; charset=UTF-8\n" "Language-Team: Japanese\n" "Language: ja_JP\n" msgctxt "Addons::name::hello_world" msgid "Hello World" msgstr "ハローワールド" msgctxt "Addons::description::hello_world" msgid "Say hello to the world." msgstr "ハローワールド!" msgctxt "SettingsOptions::hello_world::some_prop" msgid "Some Prop" msgstr "何かの設定" msgctxt "SettingsOptions::hello_world::some_dropdown" msgid "Some Dropdown" msgstr "何かのドロップダウン" msgctxt "SettingsVariants::hello_world::some_dropdown::red" msgid "Red" msgstr "赤" msgctxt "SettingsVariants::hello_world::some_dropdown::green" msgid "Green" msgstr "緑" msgctxt "SettingsVariants::hello_world::some_dropdown::blue" msgid "Blue" msgstr "青" これでインストールすると、基本設定から値を変更することができるようになります。