プラグイン > 開発について > twig に渡される変数をプラグイン内で参照したい |
開発について
フラット表示 | 前のトピック | 次のトピック |
投稿者 | スレッド |
---|---|
aaa7 |
投稿日時: 2015/12/28 17:02
対応状況: −−−
|
新米 登録日: 2015/12/28 居住地: 投稿: 4 |
twig に渡される変数をプラグイン内で参照したい 現在 eccube3 にてプラグインを作成しています。
twig 内の変数をプラグインのフックで取得したいのですが、可能でしょうか。 例えば /products/list 内の twig にある - src/Eccube/Resource/template/default/Product/list.twig <!-- ▼item_list▼ --> <div id="item_list"> <div class="row no-padding"> {% for Product in pagination %} <div class="col-sm-3 col-xs-6"> <div class="product_item"> <a href="{{ url('product_detail', {'id': Product.id}) }}"> <div class="item_photo"> <img src="{{ app.config.image_save_urlpath }}/{{ Product.main_list_image|no_image_product }}"> </div> <dl> <dt class="item_name">{{ Product.name }}</dt> {% if Product.description_list %} <dd class="item_comment">{{ Product.description_list|raw|nl2br }}</dd> {% endif %} {% if Product.hasProductClass %} {% if Product.getPrice02Min == Product.getPrice02Max %} <dd class="item_price"> {{ Product.getPrice02IncTaxMin|price }} </dd> {% else %} <dd class="item_price"> {{ Product.getPrice02IncTaxMin|price }} 〜 {{ Product.getPrice02IncTaxMax|price }} </dd> {% endif %} {% else %} <dd class="item_price">{{ Product.getPrice02IncTaxMin|price }}</dd> {% endif %} </dl> </a> </div> </div> {% endfor %} </div> </div> {% if pagination.totalItemCount > 0 %} の pagination の中を下記のような自分のプラグインの中で取得することは可能でしょうか。 - app/Plugin/MyPlugin/event.yml eccube.event.render.product_list.before: - [productList, NORMAL] - app/Plugin/MyPlugin/Event.php class Event { public function __construct($app) { $this->app = $app; } public function productList(FilterResponseEvent $event) { // ???? } } /products/list はパラメータがわたってくるので該当するコントローラと同じ処理をすれば取得可能かもしれませんが DB アクセスが無駄ですし /mypage/favorite などはパラメータがなかったりするので商品の一覧を取得できず、困っております。 eccube2 では LC_Page_Ex というページオブジェクトに全ての変数が入ってきていて、それと同様のことをやりたいと思っております。 |
フラット表示 | 前のトピック | 次のトピック |
題名 | 投稿者 | 日時 |
---|---|---|
» twig に渡される変数をプラグイン内で参照したい | aaa7 | 2015/12/28 17:02 |
Re: twig に渡される変数をプラグイン内で参照したい | tsuji | 2015/12/29 9:20 |
Re: twig に渡される変数をプラグイン内で参照したい | aaa7 | 2015/12/30 11:38 |
Re: twig に渡される変数をプラグイン内で参照したい | aaa7 | 2016/3/10 12:05 |