【问题标题】:How to create custom page before visit to store in Magento如何在访问 Magento 商店之前创建自定义页面
【发布时间】:2014-09-04 08:28:34
【问题描述】:

我在 Magento 网站上工作,客户希望应该有一个自定义登录页面,其中只有 2 个字段用户名和密码。用户名和密码与客户的注册不同。这将是静态的,说用户名是 abc,密码是 xyz . 当任何人访问该站点时,他只需输入用户名和密码即可查看商店。

我该怎么做?

【问题讨论】:

    标签: magento


    【解决方案1】:
    1. 您可以使用 basic access authentication 和 set .htpasswd
    2. 您可以将 magento 移动到子目录并通过设置 cookie 放置在根文件夹 index.php 中
    3. 您可以制作自己的模块并覆盖索引控制器(更难的方式)
    4. 您可以在 magento 的 index.php 中添加一些代码来验证 isset cookie 的值(更简单的方法)(带有原始 index.php 的备份):

      <?php
      if (!isset($_COOKIE['auth1'])){
          if(!isset($_POST['prelogin']) and !isset($_POST['prepass'])){
          //your form to post
      ?>
      <h1>Authentication Required</h1>
      <form method=post>
          <input type=text id=prelogin name=prelogin value=login>
          <input type=text id=password name=password value=password>
          <input type=submit value=submit>
      </form>
      <?php
          } else { //isset $_POST
          //...
          //your login+password check code
          //...
          setcookie("auth1", "your_md5(md5(pass))", time()+60*60*24*100, "/");
          header( 'Location: /index.php', true, 303 ); 
          }
      
      } else { //isset $_COOKIE['auth1']
      //...
      //other $_COOKIE['auth1'] checks here
      //....
      //main magento code
      }
      ?>
      

    接下来使用

    制作差异补丁
        diff -u index.php.bak index.php > auth.patch
    

    升级你的magento版本后,只需启动

        patch index.php < auth.patch
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-11-15
      • 2015-04-13
      • 2012-12-24
      • 1970-01-01
      • 2016-09-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多