在扩展中使用页面中的媒体字段
我们都可能知道以下片段,它获取页面媒体字段的第一个条目,例如在页面上显示标题图像。
10 = IMAGE
10.file {
import = uploads/media/
import.data = levelmedia: 0, slide
import.listNum = 0
}
我正在创建一个需要使用此媒体的扩展(插件,无 ItemuserFunc 等)。我不想在 php 中处理数十个打字指令来创建此图像。如何使用上面的示例通过打字稿处理媒体字段,使用核心功能而不是重新发明轮子?
所以现在我在我的扩展代码中,有一个页面记录数组。如何走得更远?下面的代码没有提供我需要的功能,因为我没有在页面级别工作(就像在 TMENU 中使用上面的 TS 时一样)。
$content .= $this->cObj->stdWrap($page['media'], $this->conf['media_stdWrap.']);
We all may know the following snippet that gets the first entry of the media field of a page to e.g. display a header image on a page.
10 = IMAGE
10.file {
import = uploads/media/
import.data = levelmedia: 0, slide
import.listNum = 0
}
I am creating an extension (plugin, no ItemuserFunc etc) which needs to work with this media. I don't want to process dozens of typoscript directives in php to create this images. How can I use the example above to process the media field through typoscript, using core functionality instead of reinventing the wheel?
So now I'm in my extension code, having an array of page records. How to get further? The code below doesn't provide the functionality I need because I am not working on the page level (like I would when using the TS from above in a TMENU).
$content .= $this->cObj->stdWrap($page['media'], $this->conf['media_stdWrap.']);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
拥有一个页面记录数组 (
$pages
),其关联键与数据库中的字段名称相同,主要是 media 字段,您只需遍历该数组并使用 Typoscript 配置创建图像。示例 1(程序员设置呈现)
示例 2(编辑器设置呈现)
它设置页面数据,以便它们可用作 Typoscript 中的
field
。配置将如下所示:示例 3(前 2 个示例的组合)
注意:这些示例完全未经测试。我已经从我的脑海里想出了它们。
Having an array of page records (
$pages
) with the associative keys same as the field names in the database, mainly the media field, you would simply walk through the array and create the images using the Typoscript configuration.Example 1 (a programmer sets the rendering)
Example 2 (an editor sets the rendering)
It sets the page data so that they are available as
field
in Typoscript. The configuration would then look something like this:Example 3 (combination of the previous 2 examples)
NOTE: These examples are completely untested. I've came up with them out of my head.