defined('WEB_PATH') || die("WEB_PATH root path not defined");
############################################################################### # 取得目前網址 ############################################################################### if(!function_exists("getCurrentUrl")){ function getCurrentUrl(){ global $_SERVER; $protocol = strpos(strtolower($_SERVER['SERVER_PROTOCOL']),'https')=== FALSE ? 'http' : 'https'; $host = $_SERVER['HTTP_HOST']; $script = $_SERVER['SCRIPT_NAME']; $params = $_SERVER['QUERY_STRING']?'?' . $_SERVER['QUERY_STRING']:""; $currentUrl = $protocol . '://' . $host . $script . $params; return $currentUrl;; } }列表流程
//預設動作 default: # ---- 目前網址 ---- $_SESSION['CurrentUrl']=getCurrentUrl(); $op="op_list"; op_list(); break;當程式有需要回到列表時,只要轉向至 $_SESSION['CurrentUrl'] 即可
<div style="margin:10px 0;"> <button onclick="window.location.href='{$smarty.session.CurrentUrl}'" type="button" class="btn btn-warning">返回</button> </div>
<button onclick="window.location.href='?op=op_form&sn={$DBV.sn}'" type="button" class="btn btn-success">編輯</button>
{* 選單管理 列表 *} {if $WEB.file_name == "nav_m.php" and $op == "op_list"} {literal} <link rel="stylesheet" href="../class/sweet-alert/sweet-alert.css" type="text/css" /> <script src="../class/sweet-alert/sweet-alert.js" type="text/javascript"></script> <script type="text/javascript"> function op_delete_js(sn){ swal({ title: '確定要刪除此資料?', text: '相關資料通通都將會被移除!', type: 'warning', showCancelButton: 1, confirmButtonColor: '#DD6B55', confirmButtonText: '確定刪除!', closeOnConfirm: false , allowOutsideClick: true }, function(){ location.href='nav_m.php?op=op_delete&sn=' + sn; }); } </script> {/literal} <div class="container" style="margin-top:20px;"> <h2 class="text-center">選單管理</h2> <table class="table table-bordered table-hover list-table"> <thead> <tr class="active"> <th class="text-center col-md-3">標題</th> <th class="text-center col-md-4">網址</th> <th class="text-center col-md-1">排序</th> <th class="text-center col-md-1">外連</th> <th class="text-center col-md-1">啟用</th> <th class="text-center col-md-2"> <button onclick="window.location.href='?op=op_form'" type="button" class="btn btn-primary btn-xs">新增</button> </th> </tr> </thead> <tbody> {foreach from=$DBV item=row} <tr> <td>{$row.title}</td> <td>{$row.url}</td> <td class="text-center">{$row.sort}</td> <td class="text-center">{$row.target}</td> <td class="text-center">{$row.enable}</td> <td class="text-center"> <button onclick="window.location.href='?op=op_show&sn={$row.sn}'" type="button" class="btn btn-warning btn-xs">瀏覽</button> <button onclick="window.location.href='?op=op_form&sn={$row.sn}'" type="button" class="btn btn-success btn-xs">編輯</button> <button onclick="javascript:op_delete_js({$row.sn});" type="button" class="btn btn-danger btn-xs">刪除</button> </td> </tr> {/foreach} </tbody> </table> </div> {/if}