未捕获的Twig_Error_Syntax:未知的“ json_encode”函数opencart

时间:2018-12-15 07:20:15

标签: twig opencart-3

我的opencart 3.0.2.0网上商店的树枝文件有问题。我得到的错误是:

  

未捕获的Twig_Error_Syntax:中的未知“ json_encode”函数   第22行中的“默认/模板/扩展名/模块/notification.twig”   /home/mk4design/public_html/system/library/template/Twig/ExpressionParser.php:574   堆栈跟踪:#0

下面是完整的树枝文件,其中json_encode有3行不正确。

有人可以帮我解决这个问题吗?

<div id="fnotification-{{ module }}" class="f-notification animated">
    <div class="notification-block">
        {% if (notification['close_status']) %}<button class="fclose-notification">×</button>{% endif %} 
        <div class="notification-image">
            {% if (custom_icons) %} 
                {% if (thumb) %} 
                    <img src="{{ thumb }}" title="{{ title }}" alt="{{ title }}">
                {% endif %}    
            {% else %} 
                <i class="fas fa {{ font_icon }}"></i>
            {% endif %} 
        </div>
        <div class="notification-text-block">
            <div class="notification-title">{{ title }}</div>
            <div class="notification-text"></div>
        </div>    
    </div>    
</div>
<script type="text/javascript">
    $('#fnotification-{{ module }}').fNotification({
        uId : {{ module }},
        Cities : {{ json_encode(city) }},
        Names : {{ json_encode(cname) }},
        Products : {{ json_encode(products) }},
        Amount : [{{ min_amount }}, {{ max_amount }}],
        Text : '{{ text }}',
        // Time Duration
        DelayFirstMin : '{{ delay_first }}',
        DisplayTime : '{{ display_time }}',
        DelayMin : '{{ delay_between }}',
        AnimationEffectOpen : '{{ in_animation }}',
        AnimationEffectClose : '{{ out_animation }}',
        DisplayTimes : '{{ cutomer_session > 0 ? cutomer_session : 0 }}',
        CloseLifetime : '{{ cookie_time }}',
        // Position
        position: '{{ position }}',
        postionTop : {{ top != '' ? top : '' }},
        postionBottom : '{{ bottom != '' ? bottom : '' }}',
        postionLeft : '{{ left != '' ? left : '' }}',
        postionRight : '{{ right != '' ? right : '' }}',
        NotificationSound :'',
        // Style
        borderRadius : '{{ border_radius }}',
        borderWidth : '{{ border_width }}',
        borderColor : '{{ border_color }}',
        backGround : '{{ bg_color }}',
        TextColor : '{{ text_color }}',
        LinkColor : '{{ link_color }}',
        Width : '{{ popup_width }}',        
        Height : '{{ popup_height }}',
        // Close Button Color
        BtnCloseColor : '{{ close_color }}',        
        BtnCloseHoverColor : '{{ close_hover_color }}',        
    });
</script>

1 个答案:

答案 0 :(得分:1)

json的Twig语法为data | json_encode()

    Just change:    
    Cities : {{ json_encode(city) }},
    Names : {{ json_encode(cname) }},
    Products : {{ json_encode(products) }},

    To:
    Cities : {{ city|json_encode() }},
    Names : {{ cname|json_encode() }},
    Products : {{ products|json_encode() }},
相关问题