加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – 如何在Prestashop中将类别页面设置为主页

发布时间:2020-12-13 18:17:40 所属栏目:PHP教程 来源:网络整理
导读:我有 http://example.com/index.php作为我的主页. 我的分类页面网址是 http://example.com/index.php?id_category=10controller=category 现在,我需要将我的主页重定向到Category Page. 我尝试了首选项 SEO网址设置商店网址基本URI as index.php?id_categor
我有 http://example.com/index.php作为我的主页.
我的分类页面网址是 http://example.com/index.php?id_category=10&controller=category

现在,我需要将我的主页重定向到Category Page.
我尝试了首选项> SEO&网址>设置商店网址>基本URI
as index.php?id_category = 10& controller = category

现在,该页面正在重定向到我的类别URL,但页面未打开.
网址显示如下
http://example.com/index.php?id_category=10&controller=category/index.php?

你这样做是错误的.做到如下:

A)简单但不推荐方式:

1)打开Controllers / IndexController.php

2)修改函数initContent如下:

public function initContent()
{

   parent::initContent();
   Tools::redirect('index.php?id_category=10&controller=category');
   $this->context->smarty->assign('HOOK_HOME',Hook::exec('displayHome'));
   $this->setTemplate(_PS_THEME_DIR_.'index.tpl');

}

B)推荐方式:

1)复制Controllers / IndexController.php以覆盖/ Controllers /文件夹
2)打开复制的文件并进行如下编辑:

class IndexController extends IndexControllerCore 
{

    public function initContent()
    {
       Tools::redirect('index.php?id_category=10&controller=category');

    }
}

3)保存文件并转到缓存文件夹.找到class_index.php,如果它在那里然后删除它.然后检查网站是否正常工作.

备注:

1)上面的代码是给你的想法,它可能会或可能不会工作.请根据您的需要进行调整.

2)在最新版本的Prestashop中,所有类都在class_index.php文件中编制索引.因此,如果您对控制器或类进行了任何覆盖,则在删除该文件之前可能无效.当向服务器发出新请求时,PS会自动为您重新生成该文件.

希望这会有所帮助.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读