如何在 Prestashop 中将分类页面设置为主页 [英] How to Set Category Page as Home Page in Prestashop
问题描述
我将 http://example.com/index.php 作为我的主页.我的类别页面 URL 是 http://example.com/index.php?id_category=10&controller=category
I am having http://example.com/index.php as my home page. My Category Page URL is http://example.com/index.php?id_category=10&controller=category
现在,我需要将我的主页重定向到类别页面.我在首选项> SEO & 中尝试过URL's > Set Shop URL > Base URI作为 index.php?id_category=10&controller=category
Now, I need to redirect my homepage to Category Page. I tried in Preferences > SEO & URL's > Set Shop URL > Base URI as index.php?id_category=10&controller=category
现在,页面正在重定向到我的类别 URL,但页面没有打开.网址是这样显示的http://example.com/index.php?id_category=10&controller=category/index.php?
Now, the page is redirecting to my Category Url but the page is not opening. the URL is showing like this http://example.com/index.php?id_category=10&controller=category/index.php?
推荐答案
你做错了.请按以下步骤操作:
You are doing it the wrong way. Do it as followed:
A) 简单但不推荐的方法:
1) 打开 Controllers/IndexController.php
1) Open Controllers/IndexController.php
2) 修改函数 initContent 如下:
2) Modify function initContent as below :
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 到 override/Controllers/文件夹2) 打开复制的文件并进行如下
1) Copy Controllers/IndexController.php to override/Controllers/ folder 2) Open the copied file and edit as below:
class IndexController extends IndexControllerCore
{
public function initContent()
{
Tools::redirect('index.php?id_category=10&controller=category');
}
}
3) 保存文件并进入缓存文件夹.找到 class_index.php ,如果存在则将其删除.然后检查网站是否工作正常.
3) Save the file and go to cache folder. Find class_index.php , if it is there then delete it. Then check the site if it works fine.
注意事项:
1) 上面的代码是给你的想法,它可能会也可能不会.请根据您的需要进行调整.
1) The above code is to give you idea, it may or may not work. Please do adjustment according to your needs.
2) 在最新版本的 Prestashop 中,所有类都在 class_index.php 文件中编入索引.因此,如果您对控制器或类进行了任何覆盖,则在您删除该文件之前它可能无法工作.当向服务器发出新请求时,PS 会自动为您重新生成该文件.
2) In latest versions of Prestashop, all classes are indexed in the class_index.php file. so if you made any override of a controller or class, it may not work until you delete that file. When a new request is made to server, PS automatically regenerate that file for you.
希望这会有所帮助.
这篇关于如何在 Prestashop 中将分类页面设置为主页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!