【问题标题】:Smarty PHP, AbanteCart E-Commerce User Agent ThemeSmarty PHP, AbanteCart 电子商务用户代理主题
【发布时间】:2013-08-09 07:10:18
【问题描述】:

我一直在使用开源 AbanteCart 电子商务来销售产品,我想知道是否有人知道有一种方法可以重定向模板以改用移动模板。

【问题讨论】:

    标签: php web open-source e-commerce smarty


    【解决方案1】:

    我想最简单的方法是挂钩所有控制器并将新变量添加到包含 template_text_id 的请求 (sf) 中...加上使用关于模板模式(桌面或移动)的 cookie。

     /**
     * redirect to mobile template if we load page in mobile device
     **/
    public function onAHook_InitEnd() {
        if ( $this->_processHooks() ) return;
        $device = $this->baseObject->request->getDeviceType();
        if ( !empty($device) && empty( $this->baseObject->request->cookie['abantecart_mobile_redirect'] ) ) {
            //set flag that redirect was done
            setcookie("abantecart_mobile_redirect", "1", time() + 3600*24);
            //set template to mobile
            $url = $this->baseObject->html->removeQueryVar($_SERVER['REQUEST_URI'], 'sf');
            $url .= '&sf=your_mobile_template_text_id';
            header ( 'Location: '. $url );
        }
    }
    private function _processHooks(){
            return $this->registry->get('config')->get('config_storefront_template') == 'your_mobile_template_text_id';
        }
    

    引擎在 core/init.php 文件中处理的变量(sf)并将桌面模板切换到移动。

    【讨论】:

      猜你喜欢
      • 2015-10-22
      • 2014-03-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-13
      • 1970-01-01
      • 2015-01-16
      • 1970-01-01
      相关资源
      最近更新 更多