如何在opencart中更改默认主页 [英] How to change default home page in opencart

查看:622
本文介绍了如何在opencart中更改默认主页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Opencart的新手.我只想要两个主页,一个页面将列出所有产品(默认情况下在opencart中),另一页面将描述有关该公司的信息.那么如何更改默认主页.

I am new to opencart. I just want two main pages, one will be listing all the products(by default in opencart) and the other will describes about the company. So how can i change the default home page.

这两个页​​面应具有不同的标题.如何设置此类页面的路由.

These two pages should have different headers. How can i set the route for this kind of pages.

是的,我尝试如下

default.tpl

在我的home.tpl我曾经使用过

<?php if(!isset($this->request->get['route'])){
    echo $header;
}else{
    echo $default;
}
?>

但是它没有呈现默认值.我还在controller/common/default.php下用以下几行

But it is not rendering default. I also created a controller under controller/common/default.php with following lines

<?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,则编写单独的头文件会更容易... 您将找到以下代码

It would be easier to write a seperate header file... if you open catalog/controller/common/home.php you will find the following code

    $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

然后您可以编辑以下文件以反映所需的样式更改:

you can then edit the following file to reflect the style changes that you want:

catalog/view/theme/default/common/headerhome.tpl

然后您可以编辑以下文件以反映所需的语言更改:

you can then edit the following file to reflect the language changes that you want:

catalog/language/english/common/headerhome.php

这意味着主页将显示headerhome,而所有其他页面将显示标准标题,如果您仅像您之前所说的那样拥有两个页面,则可以解决您的问题...

This means that the home page will show headerhome and all other pages will show the standard header, which if you are only going to have two pages like you said earlier this solves your problem...

这篇关于如何在opencart中更改默认主页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆