【问题标题】:TYPO3 fluid get @attributesTYPO3 流体获取@attributes
【发布时间】:2015-04-05 02:00:03
【问题描述】:

我想从 xml 提要中获取属性。 如果我在流体中调试数组,我可以将属性视为一个名称为@attributes 的数组:

array(6 items)
  title => 'Test Title'
  enclosure => array(1 item)
  @attributes => array(3 items)
     url => 'http://www.example.com/test.jpg' (55 chars)
     length => '83423' (5 chars)
     type => 'image/jpeg' (10 chars)

但是不能用这种语法读取 url:

enclosure.@attributes.url

也许是@符号。 是否有 Viewhelper(可能是 VHS)或我可以用来读取数据的东西?

【问题讨论】:

  • 您是否已经尝试过使用 ... ...
  • 这是一个 SimpleXMLElement。当你 <f:debug>{enclosure.@attributes}</f:debug> 时,你会得到什么也看到这个:forum.typo3.org/index.php?t=msg&goto=660534&。此外,如果你有一个控制器,你应该使用标准的 SimpleXMLElement 函数并给模板一个真正的数组或者你需要的值。
  • 我的方式似乎可行,@nbar 提到的替代解决方案更干净。
  • 是的,但我无法访问扩展程序。

标签: typo3 fluid


【解决方案1】:

感谢克里斯托夫。此解决方案有效:

<f:for each="{rss_news.enclosure}" as="item">
     <img src="{item.url}" alt="">
</f:for>

【讨论】:

    猜你喜欢
    • 2017-07-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-12
    • 1970-01-01
    相关资源
    最近更新 更多