質問 > その他 > 【EC-CUBE4.0.3】twigとtwigMacroについて |
その他
フラット表示 | 前のトピック | 次のトピック |
投稿者 | スレッド |
---|---|
katoasr |
投稿日時: 2020/2/6 13:44
対応状況: 解決済
|
半人前 登録日: 2020/1/30 居住地: 投稿: 11 |
【EC-CUBE4.0.3】twigとtwigMacroについて ▼テンプレート
[EC-CUBE] EC-CUBE4.0.3を新規インストール [レンタルサーバ]使用していない [OS] WIN10 pro [PHP] PHP7.2.26 [データベース] MySQL5.7 [WEBサーバ] httpd-2.4.39 [ブラウザ] Google Chrome [導入プラグインの有無] 無 [カスタマイズの有無] EC-CUBE 4.0 でtwigとtwigのマクロを追加してみました [現象] SampleController.phpのfunction index()で配列をindex.twigに渡して表示ようとしています。 http://localhost/sample/indexにアクセスするとRuntimeErrorとなり、HTTP 500 Internal Server Error Impossible to access an attribute ("id") on a integer variable ("1") in __string_template__ dbb243f2e991d8deb318a1724bc15d531391fc06135417c4666be3e5760536f4 at line 3. とエラーが表示されます。キャッシュ管理からキャッシュ削除を実施してもエラー内容は変わりませんでした。 なにか指摘があれば教えてください。 SampleController.phpは下記になります。 <?php namespace Customize\Controller; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Request; use \Datetime; class SampleController { /** * @Method("GET") * @Route("/sample/index", name="sample") * @Template("Sample/index.twig") */ public function index() { $Categorise = [ ["id" => 1, "name" => "suzuki", "children" => array("id" => 1,"name" => "taro")], ["id" => 2, "name" => "satou", "children" => array()] ]; return ["Categorise" => $Categorise]; } } index.twigは以下になります。 {% macro tree(Category) %} {% from _self import tree %} <a herf="{{url('product_list')}}?category_id={{ Category.id}}"> {{ Category.name}} </a> {% if Category.children|length>0 %} {{dump(Category.children|length)}} <ul> {{dump(Category.children)}} {% for ChildCategory in Category.children %} {{dump(ChildCategory)}} <li>{{tree(ChildCategory)}}</li> {% endfor %} </ul> {% endif %} {% endmacro%} {% from _self import tree%} <div class='ec-CategoryNaviRole'> <div class='ec-itemNav'> <ul class="ec-itemNav__nav"> {% for Category in Categorise %} <li> {{tree(Category)}} </li> {% endfor%} </ul> </div> </div> |
フラット表示 | 前のトピック | 次のトピック |
題名 | 投稿者 | 日時 |
---|---|---|
» 【EC-CUBE4.0.3】twigとtwigMacroについて | katoasr | 2020/2/6 13:44 |
Re: 【EC-CUBE4.0.3】twigとtwigMacroについて | tsuji | 2020/2/7 9:39 |
Re: 【EC-CUBE4.0.3】twigとtwigMacroについて | katoasr | 2020/2/7 21:45 |
Re: 【EC-CUBE4.0.3】twigとtwigMacroについて | katoasr | 2020/2/8 0:30 |