Php Joomla-前端带有标题和关闭按钮的排队消息
我正在回复一个来自ajax的通知Php Joomla-前端带有标题和关闭按钮的排队消息,php,joomla,joomla3.2,Php,Joomla,Joomla3.2,我正在回复一个来自ajax的通知 $app = JFactory::getApplication(); $app->enqueueMessage('Joomla notice', 'info'); 在前端,这将导致以下结果(注意空标题): Joomla通知 然而,我想显示一个标题和一个解散按钮通知太像它在后端,即 <div id="system-message-container"> <button type="button" class="close" dat
$app = JFactory::getApplication();
$app->enqueueMessage('Joomla notice', 'info');
在前端,这将导致以下结果(注意空标题):
Joomla通知
然而,我想显示一个标题和一个解散按钮通知太像它在后端,即
<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的方法可以做到这一点,或者我必须想出解决办法?消息通过
Joomla.renderMessages
函数呈现在media/system/js/core.js
中。
您可以在模板中用
jQuery(function() {
Joomla.renderMessages = function(messages) {
// copy / adapt the original function here.
}
});
另外,非ajax消息可以通过
html/message.php
模板覆盖进行定制。在消息排队后,我建议发送如下消息
echo new JResponseJson($data);
JFactory::getApplication()->close();
然后,您可以在客户端处理消息数组,如@Riccardo的解决方案。例如,mine ajax成功函数如下所示
success: function(responseText){
var json = jQuery.parseJSON(responseText);
Joomla.renderMessages(json.messages);
....
你可以在这里找到代码
success: function(responseText){
var json = jQuery.parseJSON(responseText);
Joomla.renderMessages(json.messages);
....