据我了解,您正在尝试从资源树中的资源中获取所有图像。并将它们显示在图像滑块中。
我猜你已经有了用于图像滑块的 javaScript。于是就有了获取图片的方法。
您有一个名为 slide-img 的 电视,对吗?好的。确保它的输出格式是文本。
如果您在带有该电视的页面中引用该图像,则可以这样称呼它
<img src="[[*slide-image]]" alt="some Image" />
如果您在一个块中调用它(使用 getResources 时将执行的操作),您可以这样调用图像:
<img src="[[+tv.slide-image]]" alt="some Image" />
看到区别了吗? * 用于同一页面内的 TV,+ 是对 占位符 的正确调用。因此,如果您使用 getResources,它会将您查询的所有内容放入微模板中的占位符中(我们在 MODX 术语中称为 chunk)
所以您的 getResources 调用可能如下所示:
[[getResources?
&parents=`-1` (the place from where getResources will dig down the tree)
&depth=`0` (how deep will it dig?)
&limit=`0` (only the default 5? no! :) )
&tpl=`slides` (this is your chunk, right?)
&sortby=`FIELD(modResource.id,[[*slide-img]])` (you will sort by the file name and folder, is that right?)
&sortdir=`ASC`
&includeTVs=`1` &processTVs=`1` &tvPrefix=`tv.` (right, right, tv. is already the default value)
]]