【发布时间】:2023-03-06 06:18:01
【问题描述】:
我想嵌入一个位于其他站点的表单,我见过https://docs.apostrophecms.org/apostrophe/modules/apostrophe-oembed,但文档没有提供如何使用该模块的任何示例。
我可以使用撇号-oembed 作为小部件吗?
【问题讨论】:
我想嵌入一个位于其他站点的表单,我见过https://docs.apostrophecms.org/apostrophe/modules/apostrophe-oembed,但文档没有提供如何使用该模块的任何示例。
我可以使用撇号-oembed 作为小部件吗?
【问题讨论】:
您需要添加一个架构字段url,并将type 设置设置为url。在lib/modules/iframe-widgets/index.js 你可以写:
module.exports = {
extend: 'apostrophe-widgets',
addFields: [
{
name: 'url',
type: 'url',
required: true
}
]
};
然后,在lib/modules/iframe-widgets/views/widget.html 中,输出你的 iframe:
<iframe src="{{ data.widget.url }}"></iframe>
应该是这样的!现在您可以像任何其他小部件一样将其包含在页面模板中:
{# Would work just as well in apos.area #}
apos.singleton(data.page, 'someName', 'iframe', {})
【讨论】: