给前端主题页面的{$header}和{$footer}添加代码。
以侧边浮动留言框效果为例
在插件或主题include.php页面的ActivePlugin里面进入接口
点击复制代码 PHP
function ActivePlugin_ytecn_fedback() {
Add_Filter_Plugin('Filter_Plugin_Zbp_MakeTemplatetags','ytecn_fedback_Zbp_MakeTemplatetags');
}
在header里添加css样式,在footer里添加js和html
点击复制代码 PHP
function ytecn_fedback_Zbp_MakeTemplatetags() {
global $zbp;
$code=$zbp->GetCSRFToken();
$send=$zbp->host."zb_users/plugin/ytecn_fedback/send.php";
$zbp->header .='<link rel="stylesheet" href="'.$zbp->host.'zb_users/plugin/ytecn_fedback/static/css/fedback.css">' . "\r\n";
$zbp->footer .= <<<eof
<div class="feedback">
<h3 class="feedbackHeader eMailIco">遇到问题?请给我们留言</h3>
<span class="closeBtn"></span>
<form class="feedbackForm" method="post" id="feedbackForm">
<p class="tips">请填写您遇到的问题,我们将回复您</p>
<input type="hidden" name="csrfToken" value="$code">
<div class="line"><textarea name="content" placeholder="*请填写留言内容"></textarea></div>
<div class="line"><input type="text" name="name" placeholder="*请填写姓名"></div>
<div class="line"><input type="text" name="tel" placeholder="*请填写电话"></div>
<input class="btn" onclick="ytecn_fedback_send()" type="submit" value="发送">
</form>
</div>
<script>
function ytecn_fedback_send(){
$.ajax({
type: "POST",
url: "$send",
data: $("#feedbackForm").serialize(),
success: function(data){
alert(data);
window.location.reload();
}
});
}
</script>
eof;
$zbp->footer .='<script src="'.$zbp->host.'zb_users/plugin/ytecn_fedback/static/js/fedback.js" type="text/javascript"></script>' . "\r\n";
}