バージョン選択

フォーラム

メニュー

オンライン状況

52 人のユーザが現在オンラインです。 (44 人のユーザが フォーラム を参照しています。)
登録ユーザ: 0
ゲスト: 52
もっと...

サイト内検索

質問 > 管理機能 > パラメータを指定した動的ブロックの呼び出し方

管理機能

新規スレッドを追加する

フラット表示 前のトピック | 次のトピック
投稿者 スレッド
rmaeda
投稿日時: 2019/7/9 14:22
対応状況: −−−
新米
登録日: 2019/7/9
居住地: 京都府
投稿: 3
Re: パラメータを指定した動的ブロックの呼び出し方
468さん

コメントありがとうございます。
ブロック用のコントローラーもカスタマイズしております。

それぞれのファイルを以下のように変更
1. src/Eccube/ControllerProvider/FrontControllerProvider.php

$c->match('/block/sales_product/{id}', '\Eccube\Controller\Block\SalesProductController::index')->bind('block_sales_product')->assert('id', '\d+');

2. src/Eccube/Controller/Block/SalesProductController.php
public function index(Application $app, $id=null) {...}

3. 新規ページ内でのブロック呼び出し
{{ render(path('block_sales_product', {'id': '100'})) }}


ログを確認
1. site_xxxxxxx.log
eccube.INFO [73b6b8f1] [bfd8b3bd] [NULL] [RouterListener:onKernelRequest:145] - Matched route "block_sales_product". {"route_parameters":{"_controller":"\\Eccube\\Controller\\Block\\SalesProductController::index","id":"100","_route":"block_sales_product"},"request_uri":"https://ドメイン名/block/sales_product/100"} [GET, /user_data/test_block, 153.133.199.188, NULL, Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36]

2. front_site_xxxxxx.log
front.ERROR [73b6b8f1] [d1e3c456] [NULL] [LogListener:onKernelException:109] - Twig_Error_Runtime: An exception has been thrown during the rendering of a template ("Some mandatory parameters are missing ("id") to generate a URL for route "block_sales_product"."). (uncaught exception) at /var/www/xxxx/src/Eccube/Resource/template/default/block.twig line 28 {"exception":"[object] (Twig_Error_Runtime(code: 0): An exception has been thrown during the rendering of a template (\"Some mandatory parameters are missing (\"id\") to generate a URL for route \"block_sales_product\".\"). at /var/www/xxxx/src/Eccube/Resource/template/default/block.twig:28, Symfony\\Component\\Routing\\Exception\\MissingMandatoryParametersException(code: 0): Some mandatory parameters are missing (\"id\") to generate a URL for route \"block_sales_product\". at /var/www/xxxx/vendor/symfony/routing/Generator/UrlGenerator.php:151)"} [GET, /user_data/test_block, 153.133.199.188, NULL, Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36]


https://ドメイン名/block/sales_product/100
id が正しく取れていない?

idは正しく引き渡していると思うのですが、
何か他にアドバイスが有れば、よろしくおねがいします。



フラット表示 前のトピック | 次のトピック


題名 投稿者 日時
   パラメータを指定した動的ブロックの呼び出し方 rmaeda 2019/7/9 11:32
     Re: パラメータを指定した動的ブロックの呼び出し方 468 2019/7/9 12:29
     » Re: パラメータを指定した動的ブロックの呼び出し方 rmaeda 2019/7/9 14:22
         Re: パラメータを指定した動的ブロックの呼び出し方 rmaeda 2019/7/9 15:47

 



ログイン


EC-CUBE公式 Amazon Payプラグイン

統計情報

総メンバー数は89,027名です
総投稿数は110,020件です

投稿数ランキング

1
seasoft
7367
2
468
3217
3
AMUAMU
2712
4
nanasess
2314
5
umebius
2085
6
yuh
1819
7
h_tanaka
1646
8
red
1570
9
mcontact
1296
10
tsuji
958
11
fukap
907
12
shutta
835
13
tao_s
799
14 ramrun 789
15 karin 689
16 sumida 641
17
homan
633
18 DELIGHT 572
19
patapata
502
20
flealog
485


ネットショップの壺

EC-CUBEインテグレートパートナー

Copyright© EC-CUBE CO.,LTD. All Rights Reserved.