我是opencart的新手.我只想要两个主要页面,一个将列出所有产品(默认情况下在opencart中),另一个将描述公司.那么我该如何更改默认主页呢.
这两个页面应该有不同的标题.如何设置此类页面的路径.
我试过如下
创建了常见的新文件 default.tpl
在我home.tpl用过的时候
<?php if(!isset($this->request->get['route'])){
echo $header;
}else{
echo $default;
}
?>
Run Code Online (Sandbox Code Playgroud)
但它不是默认渲染.我还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();
}
}
Run Code Online (Sandbox Code Playgroud)
小智 7
编写单独的头文件会更容易......如果打开,catalog/controller/common/home.php
您将找到以下代码
$this->children = array(
'common/column_left',
'common/column_right',
'common/content_top',
'common/content_bottom',
'common/footer',
'common/header'
);
Run Code Online (Sandbox Code Playgroud)
你可以改成这个
$this->children = array(
'common/column_left',
'common/column_right',
'common/content_top',
'common/content_bottom',
'common/footer',
'common/headerhome'
);
Run Code Online (Sandbox Code Playgroud)
然后打开:
catalog/view/theme/default/common/home.tpl
Run Code Online (Sandbox Code Playgroud)
并找到以下行:
<?php echo $header; ?>
Run Code Online (Sandbox Code Playgroud)
并将其更改为:
<?php echo $headerhome; ?>
Run Code Online (Sandbox Code Playgroud)
然后复制:
catalog/controller/common/header.php
并重命名它
headerhome.php
然后打开
catalog/controller/common/headerhome.php
并找到以下行
class ControllerCommonHeader extends Controller {
Run Code Online (Sandbox Code Playgroud)
并改为:
class ControllerCommonHeaderhome extends Controller {
Run Code Online (Sandbox Code Playgroud)
然后找到:
$this->language->load('common/header');
Run Code Online (Sandbox Code Playgroud)
并改为:
$this->language->load('common/header');
Run Code Online (Sandbox Code Playgroud)
然后找到以下代码:
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';
}
Run Code Online (Sandbox Code Playgroud)
并将其更改为:
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';
}
Run Code Online (Sandbox Code Playgroud)
然后复制
catalog/view/theme/default/common/header.tpl
Run Code Online (Sandbox Code Playgroud)
并重命名为:
catalog/view/theme/default/common/headerhome.tpl
Run Code Online (Sandbox Code Playgroud)
然后复制:
catalog/language/english/common/header.php
Run Code Online (Sandbox Code Playgroud)
并重命名为:
catalog/language/english/common/headerhome.php
Run Code Online (Sandbox Code Playgroud)
然后,您可以编辑以下文件以反映所需的样式更改:
catalog/view/theme/default/common/headerhome.tpl
然后,您可以编辑以下文件以反映所需的语言更改:
catalog/language/english/common/headerhome.php
这意味着主页将显示标题主页,所有其他页面将显示标准标题,如果您只有两个页面,如前所述,这将解决您的问题......