【问题标题】:How embed in my page a website with an iframe in apostropheCMS如何在我的页面中嵌入带有 iframe 的 apostropheCMS 网站
【发布时间】:2023-03-06 06:18:01
【问题描述】:

我想嵌入一个位于其他站点的表单,我见过https://docs.apostrophecms.org/apostrophe/modules/apostrophe-oembed,但文档没有提供如何使用该模块的任何示例。

我可以使用撇号-oembed 作为小部件吗?

【问题讨论】:

    标签: apostrophe-cms nunjucks


    【解决方案1】:

    看看官方custom widgets tutorial

    您需要添加一个架构字段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', {})
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-06
      • 2012-02-29
      • 1970-01-01
      • 2011-07-18
      • 2018-11-17
      相关资源
      最近更新 更多