Hello,
I'm trying to move the right_column module position to a new position in my header.tpl file. I can't seem to find where this is managed. From my research on the forum I found people mentioning a "layout.tpl" file, however I don't see this in the theme/default/template/common/ folder.
Also my cart is going to be heavily modded, with no left or right columns, so I'll need to learn how to move these modules to other areas in the template...
Would be good to know how to create new module positions, etc.
If anyone could give any help it would be greatly appreciated.
modules are strictly sideboxes by default. They can be set to left or right only. This is all done from the module config area in admin
To put them into other windows takes a bit more work. Best approach would be to add the code from catalog/controller/common/column_left.php into the header.php file and the code for looping through all the module in the column_left.tpl file into the header.tpl file.
Then you'd need to add a position of "header" in the backend for the module config so it knows where else it can go. Then you'd be able to choose the position.
To put them into other windows takes a bit more work. Best approach would be to add the code from catalog/controller/common/column_left.php into the header.php file and the code for looping through all the module in the column_left.tpl file into the header.tpl file.
Then you'd need to add a position of "header" in the backend for the module config so it knows where else it can go. Then you'd be able to choose the position.
Any other ideas on how best to do this?
I want to move the links in the "information" box to the footer, and the top level links in the "categories" box in to the header. (I still want the categories box on the left to remain as this can be used for sub categories), I also want the shopping cart data in the header.
I would have thought these arrays should be available globally so it can be accessed anywhere.
I have considered just hard coding the links in to the template files, but then any additional categories or pages can't be added so easily by the end user. This also seems bad practice as it won't make use of language files (not a problem for me as i only intend on having English). And I'm still stuck with getting the shopping cart data into the header.
I also considered tinkering with the controllers so that it passes the right data to the view files, but this seems wrong to me too. I'm guessing that would complicate upgrading to newer opencart versions in the future?
So... any ideas, i see other people using opencart have managed to do this, please tell us how you went about it? does Qphoria have the best solution?
I want to move the links in the "information" box to the footer, and the top level links in the "categories" box in to the header. (I still want the categories box on the left to remain as this can be used for sub categories), I also want the shopping cart data in the header.
I would have thought these arrays should be available globally so it can be accessed anywhere.
I have considered just hard coding the links in to the template files, but then any additional categories or pages can't be added so easily by the end user. This also seems bad practice as it won't make use of language files (not a problem for me as i only intend on having English). And I'm still stuck with getting the shopping cart data into the header.
I also considered tinkering with the controllers so that it passes the right data to the view files, but this seems wrong to me too. I'm guessing that would complicate upgrading to newer opencart versions in the future?
So... any ideas, i see other people using opencart have managed to do this, please tell us how you went about it? does Qphoria have the best solution?
It's because it's MVC. It's pretty simple to do, I've done it myself with the basket -> header etc.
1. Copy the code from the module controller file.
2. Modify the Footer controller file to handle this code too. (you may have to remove a few lines from the module contoller file, it's not just copy and paste in most cases).
3. Copy the module template file code into the footer template file.
1. Copy the code from the module controller file.
2. Modify the Footer controller file to handle this code too. (you may have to remove a few lines from the module contoller file, it's not just copy and paste in most cases).
3. Copy the module template file code into the footer template file.
Hi, can anyone help with copy/paste from module's controller to footer controller?
this is my module's controller code:
It's about adding "Subscribe to newsletter" form in footer.
Thanks in advance
this is my module's controller code:
Code: Select all
<?php
class ControllerModuleNewslettersubscribe extends Controller {
private $error = array();
public function index(){
$this->loadmodule();
$this->load->model('account/newslettersubscribe');
//check db
$this->model_account_newslettersubscribe->check_db();
}
public function subscribe(){
if($this->config->get('newslettersubscribe_thickbox')){
$prefix_eval = "";
}else{
$prefix_eval = "";
}
$this->language->load('module/newslettersubscribe');
$this->load->model('account/newslettersubscribe');
if(isset($this->request->post['subscribe_email']) and filter_var($this->request->post['subscribe_email'],FILTER_VALIDATE_EMAIL)){
if($this->config->get('newslettersubscribe_registered') and $this->model_account_newslettersubscribe->checkRegisteredUser($this->request->post)){
$this->model_account_newslettersubscribe->UpdateRegisterUsers($this->request->post,1);
echo('$("'.$prefix_eval.' #subscribe_result").html("'.$this->language->get('subscribe').'");$("'.$prefix_eval.' #subscribe")[0].reset();');
}else if(!$this->model_account_newslettersubscribe->checkmailid($this->request->post)){
$this->model_account_newslettersubscribe->subscribe($this->request->post);
echo('$("'.$prefix_eval.' #subscribe_result").html("'.$this->language->get('subscribe').'");$("'.$prefix_eval.' #subscribe")[0].reset();');
if($this->config->get('newslettersubscribe_mail_status')){
$subject = $this->language->get('mail_subject');
$message = '<table width="60%" cellpadding="2" cellspacing="1" border="0">
<tr>
<td> Email Id </td>
<td> '.$this->request->post['subscribe_email'].' </td>
</tr>
<tr>
<td> Name </td>
<td> '.$this->request->post['subscribe_name'].' </td>
</tr>';
if(isset($this->request->post['option1'])) {
$message .= '<tr> <td>'.$this->config->get('newslettersubscribe_option_field1').'</td> <td>'.$this->request->post['option1'].'</td> </tr>';
}
if(isset($this->request->post['option2'])) {
$message .= '<tr> <td>'.$this->config->get('newslettersubscribe_option_field2').'</td> <td>'.$this->request->post['option2'].'</td> </tr>';
}
if(isset($this->request->post['option3'])) {
$message .= '<tr> <td>'.$this->config->get('newslettersubscribe_option_field3').'</td> <td>'.$this->request->post['option3'].'</td> </tr>';
}
if(isset($this->request->post['option4'])) {
$message .= '<tr> <td>'.$this->config->get('newslettersubscribe_option_field4').'</td> <td>'.$this->request->post['option4'].'</td> </tr>';
}
if(isset($this->request->post['option5'])) {
$message .= '<tr> <td>'.$this->config->get('newslettersubscribe_option_field5').'</td> <td>'.$this->request->post['option5'].'</td> </tr>';
}
if(isset($this->request->post['option6'])) {
$message .= '<tr> <td>'.$this->config->get('newslettersubscribe_option_field6').'</td> <td>'.$this->request->post['option6'].'</td> </tr>';
}
$message .= '</table>';
$mail = new Mail();
$mail->protocol = $this->config->get('config_mail_protocol');
$mail->parameter = $this->config->get('config_mail_parameter');
$mail->hostname = $this->config->get('config_smtp_host');
$mail->username = $this->config->get('config_smtp_username');
$mail->password = $this->config->get('config_smtp_password');
$mail->port = $this->config->get('config_smtp_port');
$mail->timeout = $this->config->get('config_smtp_timeout');
$mail->setTo($this->config->get('config_email'));
$mail->setFrom($this->config->get('config_email'));
$mail->setSender($this->config->get('config_name'));
$mail->setSubject($subject);
$mail->setHtml($message);
$mail->send();
}
}else{
echo('$("'.$prefix_eval.' #subscribe_result").html("<span class=\"error\">'.$this->language->get('alreadyexist').'</span>");$("'.$prefix_eval.' #subscribe")[0].reset();');
}
}else{
echo('$("'.$prefix_eval.' #subscribe_result").html("<span class=\"error\">'.$this->language->get('error_invalid').'</span>")');
}
}
public function unsubscribe(){
if($this->config->get('newslettersubscribe_thickbox')){
$prefix_eval = "#TB_ajaxContent ";
}else{
$prefix_eval = "";
}
$this->language->load('module/newslettersubscribe');
$this->load->model('account/newslettersubscribe');
if(isset($this->request->post['subscribe_email']) and filter_var($this->request->post['subscribe_email'],FILTER_VALIDATE_EMAIL)){
if($this->config->get('newslettersubscribe_registered') and $this->model_account_newslettersubscribe->checkRegisteredUser($this->request->post)){
$this->model_account_newslettersubscribe->UpdateRegisterUsers($this->request->post,0);
echo('$("'.$prefix_eval.' #subscribe_result").html("'.$this->language->get('unsubscribe').'");$("'.$prefix_eval.' #subscribe")[0].reset();');
}else if(!$this->model_account_newslettersubscribe->checkmailid($this->request->post)){
echo('$("'.$prefix_eval.' #subscribe_result").html("'.$this->language->get('notexist').'");$("'.$prefix_eval.' #subscribe")[0].reset();');
}else{
if($this->config->get('option_unsubscribe')) {
$this->model_account_newslettersubscribe->unsubscribe($this->request->post);
echo('$("'.$prefix_eval.' #subscribe_result").html("'.$this->language->get('unsubscribe').'");$("'.$prefix_eval.' #subscribe")[0].reset();');
}
}
}else{
echo('$("'.$prefix_eval.' #subscribe_result").html("<span class=\"error\">'.$this->language->get('error_invalid').'</span>")');
}
}
protected function loadmodule() {
$this->language->load('module/newslettersubscribe');
$this->data['heading_title'] = $this->language->get('heading_title');
$this->data['entry_name'] = $this->language->get('entry_name');
$this->data['entry_email'] = $this->language->get('entry_email');
$this->data['entry_button'] = $this->language->get('entry_button');
$this->data['entry_unbutton'] = $this->language->get('entry_unbutton');
$this->data['option_unsubscribe'] = $this->config->get('option_unsubscribe');
$this->data['option_fields'] = $this->config->get('newslettersubscribe_option_field');
$this->data['option_fields1'] = $this->config->get('newslettersubscribe_option_field1');
$this->data['option_fields2'] = $this->config->get('newslettersubscribe_option_field2');
$this->data['option_fields3'] = $this->config->get('newslettersubscribe_option_field3');
$this->data['option_fields4'] = $this->config->get('newslettersubscribe_option_field4');
$this->data['option_fields5'] = $this->config->get('newslettersubscribe_option_field5');
$this->data['option_fields6'] = $this->config->get('newslettersubscribe_option_field6');
$this->data['thickbox'] = $this->config->get('newslettersubscribe_thickbox');
$this->data['text_subscribe'] = $this->language->get('text_subscribe');
$this->id = 'newslettersubscribe';
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/newslettersubscribe.tpl')) {
$this->template = $this->config->get('config_template') . '/template/module/newslettersubscribe.tpl';
} else {
$this->template = 'default/template/module/newslettersubscribe.tpl';
}
$this->render();
}
}
?>
Thanks in advance
Who is online
Users browsing this forum: No registered users and 10 guests