EC-CUBE4にて、新規作成(管理画面→コンテンツ管理→ページ管理)で作成したページに
コントローラ側から新規ページにパラメータを付与できず、
このようなエラーになります。
ソースコード
[SamplePageController.php]
php
1namespace Customize\Controller; 2 3use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; 4use Eccube\Controller\AbstractController; 5use Eccube\Entity\Product; 6use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; 7use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; 8 9class SamplePageController extends AbstractController 10{ 11 /** 12 * @Method("GET") 13 * @Route("/user_data/sample") 14 * @Template("sample.twig") 15 */ 16 17 public function SamplePage() 18 { 19 //カテゴリページの取得の処理 20 $Categories = $this->entityManager->getRepository('Eccube\Entity\Category')->getList(); 21 22 //サンプル画像表示処理 23 /** @var Product $product */ 24 $product = $this->entityManager->getRepository('Eccube\Entity\Product')->find(1); 25 $image = $product->getProductImage(); 26 $images = []; 27 28 foreach ($image as $ProductImage) { 29 $images[] = $ProductImage->getFileName(); 30 } 31 return [ 32 'image' => $images, 33 'Category' => $Categories, 34 ]; 35 } 36} 37 38
[sample.twig]
{% extends 'default_frame.twig' %} {% block main %} <div id="container"> <div id="boxA"> <h3>サンプル開発</h3> </div> <div id="wrapper"> <div id="boxB"> <div class="item_visual"> {% for ProductImage in image %} <div class="slide-item"><img src="{{ asset(ProductImage, 'save_image') }}"></div> {% else %} <div class="slide-item"><img src="{{ asset(''|no_image_product, 'save_image') }}"/></div> {% endfor %} </div> </div> <div id="boxC"> C(サイドバー1) </div> </div> <div id="boxD"> {% macro tree(Category) %} {% from _self import tree %} <a href="{{ url('category', { Category_id : Category.id }) }}"> {{ Category.name }} {# {% set size = Category.children | length %} ({{(size)}})#} </a> {% endmacro %} {% from _self import tree %} <div class="ec-cateoryNaviRole"> <div class="ec-itemNav"> <ul class="ec-itemNav__nav"> {% for Category in Category %} <li> {{ tree(Category) }} </li> {% endfor %} </ul> </div> </div> </div> <div id="boxE"> E(フッタ) </div> </div> </body> </html> {% endblock %}
[スタックトレース]
Twig_Error_Runtime: Variable "image" does not exist. at /var/www/html/ec-cube/app/template/default/sample.twig:57 at __TwigTemplate_ad36445279859ce375110b80239150907458d5d1cbf6b17a0909e7c4c114797c->{closure}() (/var/www/html/ec-cube/var/cache/dev/twig/de/dea9f2defaabe5bdeea9f0f42cbcc2419590e7e192caa9f9f85a46c25a53d9c3.php:110) at __TwigTemplate_ad36445279859ce375110b80239150907458d5d1cbf6b17a0909e7c4c114797c->block_main(array('app' => object(AppVariable), 'BaseInfo' => object(BaseInfo), 'eccube_config' => object(EccubeConfig), 'Layout' => object(Layout), 'Page' => object(Page), 'title' => 'サンプル', 'layoutRoleMain' => 'ec-layoutRole__mainWithColumn', '_parent' => array('app' => object(AppVariable), 'BaseInfo' => object(BaseInfo), 'eccube_config' => object(EccubeConfig), 'Layout' => object(Layout), 'Page' => object(Page), 'title' => 'サンプル', 'layoutRoleMain' => 'ec-layoutRole__mainWithColumn')), array('stylesheet' => array(object(__TwigTemplate_7c4ba192c1521dd7412ec57bb202dfc0b6e32de0d4a8d051a98ae7739e09d734), 'block_stylesheet'), 'main' => array(object(__TwigTemplate_ad36445279859ce375110b80239150907458d5d1cbf6b17a0909e7c4c114797c), 'block_main'), 'javascript' => array(object(__TwigTemplate_7c4ba192c1521dd7412ec57bb202dfc0b6e32de0d4a8d051a98ae7739e09d734), 'block_javascript'))) (/var/www/html/ec-cube/vendor/twig/twig/lib/Twig/Template.php:189) at Twig_Template->displayBlock('main', array('app' => object(AppVariable), 'BaseInfo' => object(BaseInfo), 'eccube_config' => object(EccubeConfig), 'Layout' => object(Layout), 'Page' => object(Page), 'title' => 'サンプル', 'layoutRoleMain' => 'ec-layoutRole__mainWithColumn'), array('stylesheet' => array(object(__TwigTemplate_7c4ba192c1521dd7412ec57bb202dfc0b6e32de0d4a8d051a98ae7739e09d734), 'block_stylesheet'), 'main' => array(object(__TwigTemplate_ad36445279859ce375110b80239150907458d5d1cbf6b17a0909e7c4c114797c), 'block_main'), 'javascript' => array(object(__TwigTemplate_7c4ba192c1521dd7412ec57bb202dfc0b6e32de0d4a8d051a98ae7739e09d734), 'block_javascript'))) (/var/www/html/ec-cube/var/cache/dev/twig/8a/8a236ec8c9fb9ede1f2e710f3c0877ec3724c9de9cdbede7fc6f0d451c21f9e1.php:255) at __TwigTemplate_7c4ba192c1521dd7412ec57bb202dfc0b6e32de0d4a8d051a98ae7739e09d734->doDisplay(array('app' => object(AppVariable), 'BaseInfo' => object(BaseInfo), 'eccube_config' => object(EccubeConfig), 'Layout' => object(Layout), 'Page' => object(Page), 'title' => 'サンプル', 'layoutRoleMain' => 'ec-layoutRole__mainWithColumn'), array('stylesheet' => array(object(__TwigTemplate_7c4ba192c1521dd7412ec57bb202dfc0b6e32de0d4a8d051a98ae7739e09d734), 'block_stylesheet'), 'main' => array(object(__TwigTemplate_ad36445279859ce375110b80239150907458d5d1cbf6b17a0909e7c4c114797c), 'block_main'), 'javascript' => array(object(__TwigTemplate_7c4ba192c1521dd7412ec57bb202dfc0b6e32de0d4a8d051a98ae7739e09d734), 'block_javascript'))) (/var/www/html/ec-cube/vendor/twig/twig/lib/Twig/Template.php:390) at Twig_Template->displayWithErrorHandling(array('app' => object(AppVariable), 'BaseInfo' => object(BaseInfo), 'eccube_config' => object(EccubeConfig), 'Layout' => object(Layout), 'Page' => object(Page), 'title' => 'サンプル'), array('stylesheet' => array(object(__TwigTemplate_7c4ba192c1521dd7412ec57bb202dfc0b6e32de0d4a8d051a98ae7739e09d734), 'block_stylesheet'), 'main' => array(object(__TwigTemplate_ad36445279859ce375110b80239150907458d5d1cbf6b17a0909e7c4c114797c), 'block_main'), 'javascript' => array(object(__TwigTemplate_7c4ba192c1521dd7412ec57bb202dfc0b6e32de0d4a8d051a98ae7739e09d734), 'block_javascript'))) (/var/www/html/ec-cube/vendor/twig/twig/lib/Twig/Template.php:367) at Twig_Template->display(array('app' => object(AppVariable), 'BaseInfo' => object(BaseInfo), 'eccube_config' => object(EccubeConfig), 'Layout' => object(Layout), 'Page' => object(Page), 'title' => 'サンプル'), array('main' => array(object(__TwigTemplate_ad36445279859ce375110b80239150907458d5d1cbf6b17a0909e7c4c114797c), 'block_main'))) (/var/www/html/ec-cube/var/cache/dev/twig/de/dea9f2defaabe5bdeea9f0f42cbcc2419590e7e192caa9f9f85a46c25a53d9c3.php:34) at __TwigTemplate_ad36445279859ce375110b80239150907458d5d1cbf6b17a0909e7c4c114797c->doDisplay(array('app' => object(AppVariable), 'BaseInfo' => object(BaseInfo), 'eccube_config' => object(EccubeConfig), 'Layout' => object(Layout), 'Page' => object(Page), 'title' => 'サンプル'), array('main' => array(object(__TwigTemplate_ad36445279859ce375110b80239150907458d5d1cbf6b17a0909e7c4c114797c), 'block_main'))) (/var/www/html/ec-cube/vendor/twig/twig/lib/Twig/Template.php:390) at Twig_Template->displayWithErrorHandling(array('app' => object(AppVariable), 'BaseInfo' => object(BaseInfo), 'eccube_config' => object(EccubeConfig), 'Layout' => object(Layout), 'Page' => object(Page), 'title' => 'サンプル'), array('main' => array(object(__TwigTemplate_ad36445279859ce375110b80239150907458d5d1cbf6b17a0909e7c4c114797c), 'block_main'))) (/var/www/html/ec-cube/vendor/twig/twig/lib/Twig/Template.php:367) at Twig_Template->display(array()) (/var/www/html/ec-cube/vendor/twig/twig/lib/Twig/Template.php:375) at Twig_Template->render(array()) (/var/www/html/ec-cube/vendor/symfony/twig-bridge/TwigEngine.php:49) at Symfony\Bridge\Twig\TwigEngine->render('@user_data/sample.twig', array()) (/var/www/html/ec-cube/vendor/symfony/twig-bundle/TwigEngine.php:45) at Symfony\Bundle\TwigBundle\TwigEngine->render('@user_data/sample.twig', array()) (/var/www/html/ec-cube/vendor/symfony/framework-bundle/Controller/ControllerTrait.php:284) at Symfony\Bundle\FrameworkBundle\Controller\Controller->render('@user_data/sample.twig') (Eccube/Controller/UserDataController.php:79) at Eccube\Controller\UserDataController->index(object(Request), 'sample') (/var/www/html/ec-cube/vendor/symfony/http-kernel/HttpKernel.php:151) at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1) (/var/www/html/ec-cube/vendor/symfony/http-kernel/HttpKernel.php:68) at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true) (/var/www/html/ec-cube/vendor/symfony/http-kernel/Kernel.php:200) at Symfony\Component\HttpKernel\Kernel->handle(object(Request)) (/var/www/html/ec-cube/index.php:54)
新規で作成した(http://●●●/user_data/sample)にパラメータを付与させ、ブラウザ上で表示させたいのですが
どなたかわかる方いませんか?
手順が分かる方、どうかお願い致します。
回答2件
あなたの回答
tips
プレビュー