バージョン選択

フォーラム

メニュー

オンライン状況

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

サイト内検索

質問 > その他 > 【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

 



ログイン


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

統計情報

総メンバー数は88,849名です
総投稿数は109,986件です

投稿数ランキング

1
seasoft
7367
2
468
3217
3
AMUAMU
2712
4
nanasess
2313
5
umebius
2085
6
yuh
1819
7
h_tanaka
1646
8
red
1570
9
mcontact
1291
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.