質問 > 管理機能 > パラメータを指定した動的ブロックの呼び出し方 |
管理機能
フラット表示 | 前のトピック | 次のトピック |
投稿者 | スレッド |
---|---|
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 |