如何在连接数据库或什至MySQL关闭时加载控制器

时间:2019-05-13 15:06:30

标签: php opencart opencart2.x

我想知道是否有人可以在框架连接到数据库之前帮助我加载“维护”控制器。 这将加载tpl文件。 例如,当该应用程序正在构建中并且我想关闭MySQL数据库时,但我想向获得Web的人员显示一个页面(由控制器加载的tpl文件)“我们正在构建”页面以及所有通过加载tpl文件而不需要PHP文件。

1 个答案:

答案 0 :(得分:0)

OpenCart内核在加载任何控制器之前建立数据库连接。因此,如果您打算转向维护模式,则在向用户显示任何内容之前,已经建立了数据库连接。

由于DB是如此紧密地耦合,因此实际上不可能将DB与内核分开。

唯一的解决方案是创建一个index.html文件作为维护模式html的副本,例如Paul Feakins在评论中回答。

这是可以使用的干净HTML。应该为任何人工作。

在您的根目录中,创建index.html并粘贴以下代码:

<!DOCTYPE html>
<!--[if IE]><![endif]-->
<!--[if IE 8 ]><html dir="ltr" lang="en" class="ie8"><![endif]-->
<!--[if IE 9 ]><html dir="ltr" lang="en" class="ie9"><![endif]-->
<!--[if (gt IE 9)|!(IE)]><!-->
<html dir="ltr" lang="en">
<!--<![endif]-->
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Maintenance</title>
<script src="catalog/view/javascript/jquery/jquery-2.1.1.min.js" type="text/javascript"></script>
<link href="catalog/view/javascript/bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen" />
<script src="catalog/view/javascript/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<link href="catalog/view/javascript/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
<link href="//fonts.googleapis.com/css?family=Open+Sans:400,400i,300,700" rel="stylesheet" type="text/css" />
<link href="catalog/view/theme/default/stylesheet/stylesheet.css" rel="stylesheet">
<script src="catalog/view/javascript/common.js" type="text/javascript"></script>
<link href="/image/catalog/cart.png" rel="icon" />
</head>
<body>
<nav id="top">
  <div class="container"><div class="pull-left">
  <form action="/index.html" method="post" enctype="multipart/form-data" id="form-currency">
    <div class="btn-group">
      <button class="btn btn-link dropdown-toggle" data-toggle="dropdown">                               <strong>$</strong>        <span class="hidden-xs hidden-sm hidden-md">Currency</span>&nbsp;<i class="fa fa-caret-down"></i></button>
      <ul class="dropdown-menu">
                        <li>
          <button class="currency-select btn btn-link btn-block" type="button" name="EUR">€ Euro</button>
        </li>
                                <li>
          <button class="currency-select btn btn-link btn-block" type="button" name="GBP">£ Pound Sterling</button>
        </li>
                                <li>
          <button class="currency-select btn btn-link btn-block" type="button" name="USD">$ US Dollar</button>
        </li>
                      </ul>
    </div>
    <input type="hidden" name="code" value="" />
    <input type="hidden" name="redirect" value="/index.html" />
  </form>
</div>


    <div id="top-links" class="nav pull-right">
      <ul class="list-inline">
        <li><a href="/index.html"><i class="fa fa-phone"></i></a> <span class="hidden-xs hidden-sm hidden-md">123456789</span></li>
        <li class="dropdown"><a href="/index.html" title="My Account" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-user"></i> <span class="hidden-xs hidden-sm hidden-md">My Account</span> <span class="caret"></span></a>
          <ul class="dropdown-menu dropdown-menu-right">
                        <li><a href="/index.html">Register</a></li>
            <li><a href="/index.html">Login</a></li>
                      </ul>
        </li>
        <li><a href="/index.html" id="wishlist-total" title="Wish List (0)"><i class="fa fa-heart"></i> <span class="hidden-xs hidden-sm hidden-md">Wish List (0)</span></a></li>
        <li><a href="/index.html" title="Shopping Cart"><i class="fa fa-shopping-cart"></i> <span class="hidden-xs hidden-sm hidden-md">Shopping Cart</span></a></li>
        <li><a href="/index.html" title="Checkout"><i class="fa fa-share"></i> <span class="hidden-xs hidden-sm hidden-md">Checkout</span></a></li>
      </ul>
    </div>
  </div>
</nav>
<header>
  <div class="container">
    <div class="row">
      <div class="col-sm-4">
        <div id="logo">          <h1><a href="/index.html">Your Store</a></h1>
          </div>
      </div>
      <div class="col-sm-5"><div id="search" class="input-group">
  <input type="text" name="search" value="" placeholder="Search" class="form-control input-lg" />
  <span class="input-group-btn">
    <button type="button" class="btn btn-default btn-lg"><i class="fa fa-search"></i></button>
  </span>
</div></div>
      <div class="col-sm-3"><div id="cart" class="btn-group btn-block">
  <button type="button" data-toggle="dropdown" data-loading-text="Loading..." class="btn btn-inverse btn-block btn-lg dropdown-toggle"><i class="fa fa-shopping-cart"></i> <span id="cart-total">0 item(s) - $0.00</span></button>
  <ul class="dropdown-menu pull-right">
        <li>
      <p class="text-center">Your shopping cart is empty!</p>
    </li>
      </ul>
</div>
</div>
    </div>
  </div>
</header>
<div class="container">
  <nav id="menu" class="navbar">
    <div class="navbar-header"><span id="category" class="visible-xs">Categories</span>
      <button type="button" class="btn btn-navbar navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse"><i class="fa fa-bars"></i></button>
    </div>
    <div class="collapse navbar-collapse navbar-ex1-collapse">
      <ul class="nav navbar-nav">
        <li class="dropdown"><a href="/index.html" class="dropdown-toggle" data-toggle="dropdown">Desktops</a>
        </li>
        <li class="dropdown"><a href="/index.html" class="dropdown-toggle" data-toggle="dropdown">Laptops &amp; Notebooks</a>
        </li>
        <li class="dropdown"><a href="/index.html" class="dropdown-toggle" data-toggle="dropdown">Components</a>
        </li>
        <li><a href="/index.html">Tablets</a></li>
        <li><a href="/index.html">Software</a></li>
        <li><a href="/index.html">Phones &amp; PDAs</a></li>
        <li><a href="/index.html">Cameras</a></li>
     </ul>
    </div>
  </nav>
</div>


<div id="common-maintenance" class="container">
  <div class="row">
    <div class="col-12"><h1 style="text-align:center;">We are currently performing some scheduled maintenance. <br/>We will be back as soon as possible. Please check back soon.</h1></div>
  </div>
</div>
<footer>
  <div class="container">
    <div class="row">
            <div class="col-sm-3">
        <h5>Information</h5>
        <ul class="list-unstyled">
                   <li><a href="/index.html">About Us</a></li>
                    <li><a href="/index.html">Delivery Information</a></li>
                    <li><a href="/index.html">Privacy Policy</a></li>
                    <li><a href="/index.html">Terms &amp; Conditions</a></li>
                  </ul>
      </div>
            <div class="col-sm-3">
        <h5>Customer Service</h5>
        <ul class="list-unstyled">
          <li><a href="/index.html">Contact Us</a></li>
          <li><a href="/index.html">Returns</a></li>
          <li><a href="/index.html">Site Map</a></li>
        </ul>
      </div>
      <div class="col-sm-3">
        <h5>Extras</h5>
        <ul class="list-unstyled">
          <li><a href="/index.html">Brands</a></li>
          <li><a href="/index.html">Gift Certificates</a></li>
          <li><a href="/index.html">Affiliate</a></li>
          <li><a href="/index.html">Specials</a></li>
        </ul>
      </div>
      <div class="col-sm-3">
        <h5>My Account</h5>
        <ul class="list-unstyled">
          <li><a href="/index.html">My Account</a></li>
          <li><a href="/index.html">Order History</a></li>
          <li><a href="/index.html">Wish List</a></li>
          <li><a href="/index.html">Newsletter</a></li>
        </ul>
      </div>
    </div>
    <hr>
    <p>Powered By <a href="http://www.opencart.com">OpenCart</a><br /> Your Store &copy; 2019</p>
  </div>
</footer>
<!--
OpenCart is open source software and you are free to remove the powered by OpenCart if you want, but its generally accepted practise to make a small donation.
Please donate via PayPal to donate@opencart.com
//-->
</body></html>