- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我根据本文档创建了一个联系表单模块:https://apostrophecms.org/docs/tutorials/intermediate/forms.html
提交工作和提交的表格显示在“联系表格”管理菜单项下。
我还想为每次提交生成一封电子邮件到收件人电子邮件地址。 撇号件提交小部件说我可以override the beforeInsert method to send email, if desired.
但是,我不确定应该在哪里覆盖此方法。
我应该添加 beforeInsert
内部方法/lib/modules/contact-form/index.js self.submit
方法?
或者,我应该创建 的项目级副本吗?撇号件提交小部件 , 并覆盖 beforeInsert
那里的方法(我觉得这可能太全局化了,因此不理想)?
最后,我是否应该涉及 撇号电子邮件 ?
最佳答案
我在这里的回答假设您实际上正在使用 apostrophe-pieces-submit-widgets
.因此,到目前为止,您不必编写太多代码。你已经有一个 pieces 模块,我们称之为 products
,并且您已经制作了一个提交小部件模块,products-submit-widgets
, 扩展 apostrophe-pieces-submit-widgets
.好的,不错。让我们谈谈如何将其用于发送电子邮件的其余部分。beforeInsert
方法故意一开始什么都不做,因为这是您在项目级代码中做“额外的事情”的机会。
要覆盖该方法,请创建 lib/modules/products-submit-widgets/index.js
如果您还没有这样做。您可能已经有了 addFields
的文件。和 extend
等根据 apostrophe-pieces-submit-widgets
的文档.
现在您的代码可能如下所示:
module.exports = {
// ALL OF YOUR EXISTING CONFIGURATION OF THE products-submit-widgets
// MODULE STILL GOES HERE, then...
construct: function(self, options) {
self.beforeInsert = function(req, piece, callback) {
return self.email(req, 'emailSubmission', {
piece: piece
}, {
// can also specify from and other
// valid properties for nodemailer messages here
to: 'admin@example.com',
subject: 'A new submission was received'
}, callback);
};
}
}
lib/modules/my-pieces-module-name-submit-widgets/views
在
项目级 , 创建一个
emailSubmission.html
文件并像这样填充它:
<h4>A new submission was received</h4>
A new submission was received from {{ piece.someFieldOrOther }}.
It contains this information:
{{ piece.someOtherField }}
{{ piece.yetAnotherField }}
{{ piece.etc }}
self.email
方法工作,你需要配置
apostrophe-email
模块。如果您的 Linux 服务器上已经有电子邮件传递代理,那么基本配置可能如下所示:
// in app.js
modules: {
'apostrophe-email': {
// Default "from" address. Note your email can be dropped as spam
// if this address is invalid or your server has no right to send
// email for it
from: '"Jane Doe" <jane@doe.com>',
// See the nodemailer documentation, many
// different transports are available, this one
// matches how PHP does it on Linux servers
nodemailer: {
sendmail: true,
newline: 'unix',
path: '/usr/sbin/sendmail'
}
}
}
关于apostrophe-cms - 如何通过电子邮件发送 ApostropheCMS 联系表格提交?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53586549/
我扩展了 apostrophe-express 模块实现逻辑以检查请求 header 中的 cookie。此检查中的一种情况是自动登录用户。如果 cookie 键/值与预设标志值匹配,那么我想在 ap
我想在我的 shell 脚本中用双撇号替换字符串中的所有撇号(直单引号)。我使用了以下 gsub 命令: gsub(/'/, "''", string); 但是我得到了一个错误,因为我需要插入第二个单
假设我们创建了一个简单的小部件,它可能有一个字符串或一个富文本字段。当我将小部件插入 html 时,我想指定哪个字段可见/事件。换句话说,我想向小部件添加一些自定义选项,这将改变它的行为。小部件如下所
module.exports = { extend: 'apostrophe-widgets', label: 'Learn More', instructions: 'Lea
我有两种类型的作品,一种是作者,第二种是文章。我可以显示文章列表(通过在 articles-pages 中使用 indexAjax.html 和 index.html),因为它是在撇号的 Demo 中
目前,我在 site.js 中拥有所有页面脚本,并通过 apostrophe-assets 传递它,如下所示: module.exports = { stylesheets: [...], s
我正在尝试创建编辑者角色,并具有以下权限 编辑片段页面 创作作品 在片段页面中添加小部件 我遇到的问题如下 编辑者只能编辑已添加到片段页面的小部件 编辑者在编辑作品时无法使用已上传的图片(撇号卡住,我
我必须使用 Java 解码包含以下实体的 HTML 字符串:“'”和“&apos”。我正在使用Apache Commons Lang ,但它不会解码这两个实体,因此,我目前正在执行以下操作,但我正在寻
我必须将一些额外的数据向下传递到一个小部件,以确定我的一些用户的某些所有权/可访问性选项。我按照此处的说明设置助手来传递数据: http://apostrophecms.org/docs/techni
我需要检查每个页面请求的请求 header 。我认为尝试这个的地方是在 'apostrophe-express' 模块中。我已经创建了自己的模块“auth”,它扩展了“apostrophe-expre
有没有办法改进这个正则表达式来搜索所有以 t 结尾的词,包括 don't ?我还想打印整个单词,而不仅仅是最后一个 t . r"\b\w*\Wt\b|\b\w*t\b" 我不得不写出 2 个单独的案例
如何在 Google 表格中的 SQL 查询中转义撇号? 这是我的功能: =QUERY(QUERY(IMPORTRANGE("XXXXXXX", "XXXXXX!A1:C"),"SELECT * WH
我根据本文档创建了一个联系表单模块:https://apostrophecms.org/docs/tutorials/intermediate/forms.html 提交工作和提交的表格显示在“联系表
我正在为我们的网站运行 SEO,我们的网站正在使用 Apostrophe-cms。但是,SEO 描述字段有 155 个字符的限制。搜索引擎优化说明: 我想在页面设置中再添加一个字段,例如文本字段。页面
我对 Clojure 相当陌生,我不确定我是否完全理解 Clojure 中撇号和反引号之间的区别。 (def x 5) ;; Question 1 (+ x x) ;; evaluates to 1
我使用以下代码来更新我的Windows窗体之一上的“公司”信息。当用户将公司名称放在txtBusName中,例如“ Sandy's Place ”时,我收到Incorrect Syntax near
我在 Apostrophe CMS 中创建自定义图像小部件时遇到问题。当前apostrophe-images-widgets适用于更多图像,但我需要网站 Logo 的特殊情况,因为它需要特定的 css
我使用 Apostrophe CMS 创建了一个项目并不断开发新的页面和文章。我们发布的内容(文章和页面)将对公众(非登录用户)和登录用户(管理员)可用。 我已经了解 Apostrophe CMS 中
我正尝试按如下方式为我的媒体播放器运行查询: audioCursor = getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONT
我的目标是在文本中找到一个词。需要注意的是,我需要将撇号视为文本。 让我用一个例子来解释。假设我要在文本中查找单词 don:don't trust don。我需要匹配 don 而不是 don't。 我
我是一名优秀的程序员,十分优秀!