OctoberCMS有一个方便的弹出功能 https://octobercms.com/docs/ui/popup
虽然我在这里找到了AJAX处理程序https://octobercms.com/docs/ajax/handlers
我试图在访问者访问主页上的网站时发出弹出消息。但是我无法弄清楚这样做的方法。我想我可以使用AJAX处理程序来帮助它说你可以使用onInit()
,但我没有做到。有没有一种正确而简单的方法来做这件事?
答案 0 :(得分:2)
我想您希望them notification
访问user
的网站时显示first time
。
是的,you don't need ajax for
您可以直接使用Modal API
<!-- popup markup -->
<div class="control-popup modal fade" id="contentBasic">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<button type="button" class="close" data-dismiss="modal">×</button>
<p>This is a very basic example of a popup...</p>
</div>
</div>
</div>
</div>
<!-- put scripts will make sure that it add script at very bottom of body tag -->
{% put scripts %}
<script>
// we need to show popup when document is fully loaded
$(document).ready(function() {
// check key is exist or not if exist then we dont show popup
if(localStorage.getItem('isPopupShown') === null){
// if key is not exist means user landed on page first time
$("#contentBasic").modal('show');
// mark popup is already showed to user
localStorage.setItem('isPopupShown',1)
}
});
</script>
{% endput %}
加载页面后show user popup
(仅限第一次)。
如果还有任何问题请发表评论。