从 Drupal 7 中的模块调用 $site_name 变量

发布于 2024-12-13 14:18:04 字数 394 浏览 4 评论 0原文

我正在创建一个自定义模块,该模块使用表单 API 并在提交时发送电子邮件 - 但是,我希望将“发件人”电子邮件名称设为站点名称(例如,[电子邮件受保护])。在 phptemplate 中,您可以使用 $site_name,但这似乎在模块中不起作用。我尝试在函数参数中调用 &$variables 或 &$variable 或 &$vars 并对其进行 DSMed,但仍然没有任何结果。有什么想法吗?

非常感谢! 马特

I'm creating a custom module that has uses the form API and sends an email on submission- however, I want to make the 'from' email name to be the site name (eg, <My Drupal Site> [email protected]). In phptemplate you can use $site_name, but that doesn't work from a module it seems. I've tried calling &$variables or &$variable or &$vars in the function argument and DSMed it but still nothing. Any ideas?

Many thanks!
Matt

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

不乱于心 2024-12-20 14:18:04

您可以使用:

variable_get('site_name');

模块或模板文件中的任何位置:)

You can use:

variable_get('site_name');

anywhere in a module or template file :)

別甾虛僞 2024-12-20 14:18:04

我建议在核心中使用的方法:

variable_get('site_name', 'Drupal');

variable_get() 中包含默认值是一个很好的做法。

I'd suggest the approach used in core:

variable_get('site_name', 'Drupal');

It's good practice to include the default value in variable_get().

蓝眼泪 2024-12-20 14:18:04

完成...我挖掘了集合并获取了代码,但没有一个被清理过...清理序列化对象可能会破坏东西,所以这是有道理的

Done...I dug through the set and get code and none of it ever is sanitized...sanitizing serialized objects would probably break stuff so it makes sense

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文