gpt4 book ai didi

php - Joomla - enqueueMessage 在前端带有标题和关闭按钮

转载 作者:行者123 更新时间:2023-12-02 01:08:22 25 4
gpt4 key购买 nike

我正在使用

从 ajax 调用返回通知
$app = JFactory::getApplication();
$app->enqueueMessage('Joomla notice', 'info');

在前端这会产生以下结果(注意空标题):

<div id="system-message-container">
<div id="system-message" class="alert alert-info">
<h4 class="alert-heading"></h4>
<div>
<p>Joomla notice </p>
</div>
</div>
</div>

但是我想像在后端一样显示带有标题和关闭按钮的通知,即

<div id="system-message-container">
<button type="button" class="close" data-dismiss="alert">×</button>
<div class="alert alert-info">
<h4 class="alert-heading">Info</h4>
<p>Joomla notice</p>
</div>
</div>

是否有 Joomla 方法可以做到这一点,还是我必须想出一个变通办法?

最佳答案

消息由 Joomla.renderMessages 函数呈现在 media/system/js/core.js 中。你可以在你的模板中用

覆盖它
jQuery(function() {
Joomla.renderMessages = function(messages) {
// copy / adapt the original function here.
}
});

此外,非 ajax 消息可以通过 html/message.php 模板覆盖进行自定义。

关于php - Joomla - enqueueMessage 在前端带有标题和关闭按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19871287/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com