关键“路径"对于带有键“"的数组转储说它不存在时不存在不存在、数组、说它、路径

由网友(深藍的海將我淹沒、)分享简介:我目前正在开发一个使用 symfony2 作为底层框架和 twig 作为模板引擎的 cms.I'm currently working on a cms using symfony2 as the underlying framework and twig as the template engine.我的问题如下...

我目前正在开发一个使用 symfony2 作为底层框架和 twig 作为模板引擎的 cms.

I'm currently working on a cms using symfony2 as the underlying framework and twig as the template engine.

我的问题如下:

此时

{% for image in images %}
    {{ dump(image.path is defined) }}
{% endfor %}

为数组中的每个元素返回 true,...

returns true for each element in the array,...

...但是这个

{% for image in images %}
    {{ image.path}}
{% endfor %}

抛出异常.

带有键"的数组的键路径"不存在

图像数组的树枝转储返回:

A twig-dump of the images-array returns this:

array(2) {
    [0]=> object(stdClass)#2759 (9) {
        ["id"]=> string(5) "17795"
        ["typ"]=> string(3) "jpg"
        ["path"]=> string(10) "Tulips.jpg"
    }
    [1]=> object(stdClass)#2874 (9) {
        ["id"]=> string(5) "17796"
        ["typ"]=> string(3) "jpg"
        ["path"]=> string(14) "Hydrangeas.jpg"
    }
}

这对我来说似乎很矛盾,我真的不明白这一点.有人有想法吗?非常感谢,截止日期即将到来...:/

This seems to be paradox to me and i really don't understand this. Has someone an Idea? I would be very thankful, deadlines are coming... :/

推荐答案

我想你创建了多维数组.也可以在树枝模板中尝试 foreach 循环以获取图像

I think u created multidimensional array. Try foreach loop in twig template for image also

{% for image in images %}
    {% for i in image %}
       {{ i.datei }}
    {% endfor %}
{% endfor %}
阅读全文

相关推荐

最新文章