Reputation: 150
For example in Wordpress you can call to home with:
<?php echo home_url(); ?>
But in OpenCart I can't find a similar function. In my header this works:
<?php echo $base; ?>
But not on other templates in my theme. Someone who got a global function for this in OpenCart? Or a library to share, would be perfect!
I work with OpenCart 2.0
Upvotes: 0
Views: 1555
Reputation: 19
Copy from controller/common/home/header.php
$this->load->language('common/header');
$data['text_home'] = $this->language->get('text_home');
and
$data['home'] = $this->url->link('common/home');
Add these to whichever controller needs them Copy from header.tpl
href="<?php echo $home; ?>"
add to whichever template needs it.
Would that not cover SEO and link needs?
Upvotes: 0
Reputation: 2822
<?php echo $this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL'); ?>
Upvotes: 0
Reputation: 15151
The correct way to do this in OpenCart is to use
<?php echo $this->url->link('common/home'); ?>
Note that this adds the full URL and route, not just /
which is not possible using the SEO URL class without modification
Upvotes: 0
Reputation: 150
In the controller of the page, in my case footer.php I pasted this:
if ($this->request->server['HTTPS']) {
$server = $this->config->get('config_ssl');
} else {
$server = $this->config->get('config_url');
}
$data['base'] = $server;
And then in my template, footer.tpl I could use:
<?php echo $base; ?>
Upvotes: 0