私はオープンカートフレームワークの新人です。ファイルのアップロードと直接チェックアウト ボタン (ショッピング カート ページのように) を備えたカスタム ページの作成に取り組んでいます。このページでは、(tpl files)
連絡先フォームに基づいて既にビューとコントローラーを作成しています。ここに私のコントローラー:
<?php
class ControllerInformationRequest extends Controller {
private $error = array();
public function index() {
$this->language->load('information/request');
$this->document->setTitle($this->language->get('heading_title'));
$this->load->model('account/request');
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
$this->redirect($this->url->link('information/request/success'));
}
$this->data['breadcrumbs'] = array();
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home'),
'separator' => false
);
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('information/request'),
'separator' => $this->language->get('text_separator')
);
$this->data['heading_title'] = $this->language->get('heading_title');
$this->data['text_location'] = $this->language->get('text_location');
$this->data['text_contact'] = $this->language->get('text_contact');
$this->data['text_address'] = $this->language->get('text_address');
$this->data['text_telephone'] = $this->language->get('text_telephone');
$this->data['text_fax'] = $this->language->get('text_fax');
$this->data['entry_name'] = $this->language->get('entry_name');
$this->data['entry_email'] = $this->language->get('entry_email');
$this->data['entry_enquiry'] = $this->language->get('entry_enquiry');
$this->data['entry_captcha'] = $this->language->get('entry_captcha');
$this->data['entry_phone'] = $this->language->get('entry_phone');
if (isset($this->error['name'])) {
$this->data['error_name'] = $this->error['name'];
} else {
$this->data['error_name'] = '';
}
if (isset($this->error['telephone'])) {
$this->data['error_telephone'] = $this->error['telephone'];
} else {
$this->data['error_telephone'] = '';
}
if (isset($this->error['email'])) {
$this->data['error_email'] = $this->error['email'];
} else {
$this->data['error_email'] = '';
}
if (isset($this->error['enquiry'])) {
$this->data['error_enquiry'] = $this->error['enquiry'];
} else {
$this->data['error_enquiry'] = '';
}
if (isset($this->error['captcha'])) {
$this->data['error_captcha'] = $this->error['captcha'];
} else {
$this->data['error_captcha'] = '';
}
$this->data['button_continue'] = $this->language->get('button_continue');
$this->data['action'] = $this->url->link('information/request');
$this->data['store'] = $this->config->get('config_name');
$this->data['address'] = nl2br($this->config->get('config_address'));
$this->data['telephone'] = $this->config->get('config_telephone');
$this->data['fax'] = $this->config->get('config_fax');
if (isset($this->request->post['name'])) {
$this->data['name'] = $this->request->post['name'];
} else {
$this->data['name'] = $this->customer->getFirstName();
}
if (isset($this->request->post['email'])) {
$this->data['email'] = $this->request->post['email'];
} else {
$this->data['email'] = $this->customer->getEmail();
}
if (isset($this->request->post['telephone'])) {
$this->data['telephone'] = $this->request->post['telephone'];
} else {
//$this->data['phone'] = $this->customer->getPhone();
$this->data['telephone'] = $this->customer->getTelephone();
}
if (isset($this->request->post['enquiry'])) {
$this->data['enquiry'] = $this->request->post['enquiry'];
} else {
$this->data['enquiry'] = '';
}
if (isset($this->request->post['captcha'])) {
$this->data['captcha'] = $this->request->post['captcha'];
} else {
$this->data['captcha'] = '';
}
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/information/request.tpl')) {
$this->template = $this->config->get('config_template') . '/template/information/request.tpl';
} else {
$this->template = 'default/template/information/request.tpl';
}
$this->load->model('account/request');
$this->children = array(
'common/column_left',
'common/column_right',
'common/content_top',
'common/content_bottom',
'common/footer',
'common/header'
);
$this->response->setOutput($this->render());
}
public function success() {
$this->language->load('information/request');
$this->document->setTitle($this->language->get('heading_title'));
$this->data['breadcrumbs'] = array();
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home'),
'separator' => false
);
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('information/request'),
'separator' => $this->language->get('text_separator')
);
$this->data['heading_title'] = $this->language->get('heading_title');
$this->data['text_message'] = $this->language->get('text_message');
$this->data['button_continue'] = $this->language->get('button_continue');
$this->data['continue'] = $this->url->link('common/home');
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/success.tpl')) {
$this->template = $this->config->get('config_template') . '/template/common/success.tpl';
} else {
$this->template = 'default/template/common/success.tpl';
}
$this->children = array(
'common/column_left',
'common/column_right',
'common/content_top',
'common/content_bottom',
'common/footer',
'common/header'
);
$this->response->setOutput($this->render());
}
private function validate() {
if ((utf8_strlen($this->request->post['name']) < 3) || (utf8_strlen($this->request->post['name']) > 32)) {
$this->error['name'] = $this->language->get('error_name');
}
if (!preg_match('/^[^\@]+@.*\.[a-z]{2,6}$/i', $this->request->post['email'])) {
$this->error['email'] = $this->language->get('error_email');
}
if ((utf8_strlen($this->request->post['enquiry']) < 10) || (utf8_strlen($this->request->post['enquiry']) > 3000)) {
$this->error['enquiry'] = $this->language->get('error_enquiry');
}
if (empty($this->session->data['captcha']) || ($this->session->data['captcha'] != $this->request->post['captcha'])) {
$this->error['captcha'] = $this->language->get('error_captcha');
}
if (!$this->error) {
return true;
} else {
return false;
}
}
public function captcha() {
$this->load->library('captcha');
$captcha = new Captcha();
$this->session->data['captcha'] = $captcha->getCode();
$captcha->showImage();
}
}
?>
ビュー.tpl
ファイルには、名前、電子メール アドレス、電話番号、メッセージ、キャプチャ画像が含まれています。そのデータをデータベースに保存したいだけです。特定の場所にモデル ファイルを既に作成しています。モデル ファイルを呼び出す方法 ( $this->load->model('account/request');
)...そのt working and its can
データベースは保存されていません。また、どうすれば可能ですか?これに対する解決策を教えてください....