![](/img/trans.png)
[英]opencart how to display all categories with images on home page opencart 1.5.1.3
[英]How to change default home page in opencart
我是opencart的新手。 我只想要两个主页,一个页面将列出所有产品(默认情况下在opencart中),另一页面将描述有关该公司的信息。 因此,如何更改默认主页。
这两个页面应具有不同的标题。 我如何为此类页面设置路线。
是的,我尝试如下
在default.tpl
下以common创建了新文件
在我的home.tpl
<?php if(!isset($this->request->get['route'])){
echo $header;
}else{
echo $default;
}
?>
但这不是默认设置。 我还用以下几行在controller/common/default.php
下创建了一个控制器
<?php
class ControllerCommonDefault extends Controller {
public function index() {
$this->template = $this->config->get('config_template') . '/template/common/default.tpl';
$this->render();
}
}
编写单独的头文件会更容易...如果打开catalog/controller/common/home.php
您将找到以下代码
$this->children = array(
'common/column_left',
'common/column_right',
'common/content_top',
'common/content_bottom',
'common/footer',
'common/header'
);
您可以将其更改为
$this->children = array(
'common/column_left',
'common/column_right',
'common/content_top',
'common/content_bottom',
'common/footer',
'common/headerhome'
);
然后打开:
catalog/view/theme/default/common/home.tpl
并找到以下行:
<?php echo $header; ?>
并将其更改为:
<?php echo $headerhome; ?>
然后复制:
catalog/controller/common/header.php
并重命名
headerhome.php
然后打开
catalog/controller/common/headerhome.php
并找到以下行
class ControllerCommonHeader extends Controller {
并更改为:
class ControllerCommonHeaderhome extends Controller {
然后找到:
$this->language->load('common/header');
并更改为:
$this->language->load('common/header');
然后找到以下代码:
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/header.tpl')) {
$this->template = $this->config->get('config_template') . '/template/common/header.tpl';
} else {
$this->template = 'default/template/common/header.tpl';
}
并将其更改为:
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/headerhome.tpl')) {
$this->template = $this->config->get('config_template') . '/template/common/headerhome.tpl';
} else {
$this->template = 'default/template/common/headerhome.tpl';
}
然后复制
catalog/view/theme/default/common/header.tpl
并重命名为:
catalog/view/theme/default/common/headerhome.tpl
然后复制:
catalog/language/english/common/header.php
并重命名为:
catalog/language/english/common/headerhome.php
然后,您可以编辑以下文件以反映所需的样式更改:
catalog/view/theme/default/common/headerhome.tpl
然后,您可以编辑以下文件以反映所需的语言更改:
catalog/language/english/common/headerhome.php
这意味着首页将显示headerhome,而所有其他页面将显示标准标题,如果您仅像您之前所说的那样拥有两个页面,则可以解决您的问题...
$this->request->get['route']
您将使用这段代码获得当前页面路径。 根据此条件,在common / header.php控制器文件中编写一个条件,并使用单独的模板文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.