[英]How to display message in PHP using certain string in the URL?
我已經安裝了WHMCS,並且嘗試創建一個消息氣泡,當有人通過特定鏈接訪問它時,該氣泡將顯示。
就像有人訪問此鏈接一樣,他們將看到正常頁面-https://example.com/billing/clientarea.php?action=details
但是,如果有人訪問https://example.com/billing/clientarea.php?action=details&status=incomplete
他們會收到一條消息。
我已經設置了該消息,並且該消息顯示在默認鏈接上。 但是我不知道如何僅在第二個鏈接上進行設置? 我正在使用WHMCS。
誰能指導我?
消息氣泡的代碼。
<div class="alert alert-danger">
<strong>The following errors occurred:</strong>
<ul>
<li>Please enter your address and click on save to proceed. Once Saved, then only you will be able to access the client area.</li>
</ul>
</div>
編輯:解決方案已添加
非常感謝@symlink的幫助,您的方法可在PHP上運行,但對於WHMCS / smarty php,則需要其他代碼,這也是一個非常簡單的代碼,大聲笑。
{if $smarty.get.status eq incomplete}
{include file="$template/includes/alert.tpl" type="info" msg="Please fill the form to continue with our services."}
{else}
{/if}
如果$GET
參數存在,則將一個類添加到消息div中,使其顯示:
PHP / HTML
<?php
$class = "";
if(isset($GET["status"]) && $GET["status"] === "incomplete"){
$class = "show";
}
?>
<div class="alert alert-danger <?php echo $class ?>">
<strong>The following errors occurred:</strong>
<ul>
<li>Please enter your address and click on save to proceed. Once Saved,
then only you will be able to access the client area.</li>
</ul>
</div>
的CSS
.alert.alert-danger{
display: none;
}
.alert.alert-danger.show{
display: block;
}
如果編輯模板,則使WHMCS保持最新狀態變得更加困難。 我建議使用鈎子輸出一些JS,以將適當的警報注入您的頁面。
也許ClientAreaFooterOutput掛鈎點? https://developers.whmcs.com/hooks-reference/output/#clientareafooteroutput
就像是:
<?php
add_hook('ClientAreaFooterOutput', 1, function($vars) {
$status = App::getFromRequest('status'); //This is handy and sanitised
return <<<HTML
jQuery(document).on('ready', function() {
if ('{$status}' == 'incomplete') {
//Add your code here to output the alert where you wish
}
});
HTML;
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.