Получилось вывести модуль подписки в футер, но не получается прописать ему стили. http://beisbolochka.in.ua/genskie_shapki/_903.html Вот код вывода модуля Код: <div class="box"> <div class="box-heading"><?php echo $heading_title; ?></div> <div class="box-content"> <div class="subscribe<?php echo $module; ?>"> <span><?php echo $text_enter_email; ?></span><br/> <input type="text" name="subscribe_email<?php echo $module; ?>" value="" /> <input type="button" value="<?php echo $button_subscribe; ?>" onclick="addSubscribe(<?php echo $module; ?>);" class="button" /> </div> </div> </div> Подскажите пожалуйста, что нужно прописать в stylesheet.css
Добавьте ему собственный класс и на него навешивайте правила. Например: HTML: <div class="box subscribe-box"> Код: .subscribe-box .box-heading{ } И т.д.
я добавила, но почему-то не получается, поменяла в коде <div class="box"> на <div class="box subscribe-box"> но стили на месте, пробывала прописывать ширину высоту блока не получается, вы не могли бы поподробнее описать вот такие стили у меня: .subscribe-box .box-heading{ width: 100px; height:50px; }
Тьфу, ссылка же в первом посте. Не знаю, куда вы стили вписываете, но файле стилей их нет, потому и никакого результата нет. Вписывать надо в /catalog/view/theme/default/stylesheet/stylesheet.css А ещё у вас в этом модуле вот такие ошибки: PHP: <b>Notice</b>: Undefined variable: module in <b>/home/beisbolo/beisbolochka.in.ua/www/catalog/view/theme/default/template/common/footer.tpl</b> on line <b>9</b> Поубирайте там вообще эту переменную $module, для этого модуля в ней смысла нет. И похоже, вы забыли подключить скрипт, который должен обрабатывать сабмит в модуле.
я стили именно в stylesheet.css и вписываю, сделала как вы сказали убрала $module вот что получилось Код: <div class="box subscribe-box"> <div class="box-heading"><?php echo $heading_title; ?></div> <div class="box-content"> <div class="subscribe"> <span><?php echo $text_enter_email; ?></span><br/> <input type="text" name="subscribe_email" value="" /> <input type="button" value="<?php echo $button_subscribe; ?>" onclick="addSubscribe;" class="button" /> </div> </div> </div> Код: стили вот такие, получилось поменять только ширину .subscribe-box { width: 200px; height: 100px; } --- Добавлено, 5 окт 2015 --- но стили в футере хромают, как стедалать одинаковые отступы со всех боков футера?
Теперь я вижу эти стили. Раньше их не было в файле. Высота не меняется потому, что надо её у .box-content менять. И форма не будет работать пока вы не подключите её скрипт. У вас по клику на кнопке должна срабатывать функция addSubscribe, но сейчас её нет на странице.
Скрипт должен был бы подключаться в контроллере модуля. Посмотрите файл контроллера, он должен быть в /catalog/controller/module/. Учитывая, что эта форма будет на всех страницах, а скрипт, вероятно, маленький, его лучше просто скопировать в основной файл скриптов common.js. Для начала найдите сам скрипт.
Вот файл, который я нашла по пути catalog/controller/module/subscribe.php Код: <?php class ControllerModuleSubscribe extends Controller { private $error = array(); public function index($setting = array()) { if (isset($this->request->post['module'])) { $module = $this->request->post['module']; } else { $module = $setting['subscribe_id']; $this->document->addScript('catalog/view/javascript/subscribe.js'); } $this->data['module'] = $module; $this->language->load('module/subscribe'); $this->data['heading_title'] = $this->language->get('heading_title'); $this->data['button_subscribe'] = $this->language->get('button_subscribe'); $this->data['text_enter_email'] = $this->language->get('text_enter_email'); if (isset($this->error['email'])) { $this->data['error_email'] = $this->error['email']; } else { $this->data['error_email'] = ''; } if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/subscribe.tpl')) { $this->template = $this->config->get('config_template') . '/template/module/subscribe.tpl'; } else { $this->template = 'default/template/module/subscribe.tpl'; } $this->response->setOutput($this->render()); } public function addSubscribe() { $json = array(); $this->load->model('catalog/subscribe'); $this->language->load('module/subscribe'); $email_subscriber = $this->request->post['email']; if ((utf8_strlen($email_subscriber) > 96) || !preg_match('/^[^\@]+@.*\.[a-z]{2,6}$/i', $email_subscriber)) { $json['error'] = $this->language->get('error_email'); } elseif ($this->model_catalog_subscribe->checkEmail($email_subscriber)) { $json['error'] = $this->language->get('error_customer'); } if (!$json && isset($this->request->post['module'])) { $subscribes = $this->config->get('subscribe_module'); $module = $this->request->post['module']; $email_alert = $subscribes[$module]['email_alert']; $subscribe_confirm = $subscribes[$module]['subscribe_confirm']; if ($subscribe_confirm) { $json['success'] = $this->language->get('text_subscribe_confirm'); $status = 0; } else { $json['success'] = $this->language->get('text_success'); $status = 1; } $data = array( 'email' => $email_subscriber, 'status' => $status ); $this->model_catalog_subscribe->addSubscribe($data); $subject = sprintf($this->language->get('text_hello_subscriber'), $this->config->get('config_name')); /* client software does not support HTML email - derive the minimum information - $text */ if ($subscribe_confirm) { $link = $this->url->link('module/subscribe/confirmSubscribe&key=' . $this->keyCoding($email_subscriber), '', 'SSL'); $text = $this->language->get('text_subscribe_active') . $link . "\n\n"; $html_message = sprintf($this->language->get('text_subscribe_active_html'), $link); } else { $text = sprintf($this->language->get('text_hello_subscriber'), $this->config->get('config_name')) . "\n\n"; $html_message = sprintf($this->language->get('text_hello_subscriber'), $this->config->get('config_name')); } $text_mail = $this->model_catalog_subscribe->getAuthDescription((int) $this->config->get('config_language_id')); $html = '<html dir="ltr" lang="en">' . "\n"; $html .= ' <head>' . "\n"; $html .= ' <title>' . $subject . '</title>' . "\n"; $html .= ' <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">' . "\n"; $html .= ' </head>' . "\n"; $html .= ' <body><div>' . $html_message . '</div>' . html_entity_decode($text_mail, ENT_QUOTES, 'UTF-8') . '</body>' . "\n"; $html .= '</html>' . "\n"; $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($email_subscriber); $mail->setFrom($this->config->get('config_email')); $mail->setSender($this->config->get('config_name')); $mail->setSubject($subject); $mail->setHtml($html); $mail->setText($text); $mail->send(); if ($email_alert) { $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(sprintf($this->language->get('text_email_subject_shop'), $this->config->get('config_name', $email_subscriber))); $mail->setText(sprintf($this->language->get('text_email_text'), $email_subscriber)); $mail->send(); } } $this->response->setOutput(json_encode($json)); } public function confirmSubscribe() { $this->load->model('catalog/subscribe'); $this->language->load('module/subscribe'); $this->document->setTitle($this->language->get('heading_title_confirm')); $this->document->setDescription($this->config->get('config_meta_description')); $this->data['heading_title'] = $this->language->get('heading_title_confirm'); $this->data['breadcrumbs'] = array(); $this->data['breadcrumbs'][] = array( 'href' => $this->url->link('common/home'), 'text' => $this->language->get('text_home'), 'separator' => false ); $this->data['breadcrumbs'][] = array( 'href' => $this->url->link('module/subscribe/confirmSubscribe', '', 'SSL'), 'text' => $this->language->get('heading_title_confirm'), 'separator' => $this->language->get('text_separator') ); $this->data['text_message_confirm'] = $this->language->get('text_message_confirm'); $this->data['button_continue'] = $this->language->get('button_continue'); if (isset($this->request->get['key'])) { $key = $this->request->get['key']; } else { $key = 0; } if ($this->keyValidate($key)) { $subscribe = $this->getUncheckingSubscriber($key); $data = array( 'email' => $subscribe['email'], 'status' => 1 ); $this->model_catalog_subscribe->editSubscribe($data); } if (isset($this->error['warning'])) { $this->data['error_warning'] = $this->error['warning']; } else { $this->data['error_warning'] = ''; } $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/account/subscribe.tpl')) { $this->template = $this->config->get('config_template') . '/template/account/subscribe.tpl'; } else { $this->template = 'default/template/account/subscribe.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 keyValidate($key) { $this->load->model('catalog/subscribe'); $this->language->load('module/subscribe'); if (isset($key) && !$this->getUncheckingSubscriber($key)) { $this->error['warning'] = sprintf($this->language->get('text_message_error'), $this->url->link('information/contact')); } if (!$this->error) { return true; } else { return false; } } private function getUncheckingSubscriber($key) { $data = array(); foreach ($this->model_catalog_subscribe->getSubscribers() as $subscribe) { if ($this->keyDecoding($subscribe['email']) == $key) { $data = array( 'email' => $subscribe['email'] ); break; } } return $data; } private function keyCoding($key) { $code_key = md5($key); return $code_key; } private function keyDecoding($key) { $decode_key = md5($key); return $decode_key; } } ?> Это и есть скрипт? --- Добавлено, 6 окт 2015 --- $this->data['heading_title'] = $this->language->get('heading_title'); $this->data['button_subscribe'] = $this->language->get('button_subscribe'); $this->data['text_enter_email'] = $this->language->get('text_enter_email'); эти строки у меня прописаны по пути catalog/controller/common/footer.php
PHP: $this->document->addScript('catalog/view/javascript/subscribe.js'); Вот подключение скрипта. Как вы этот модуль в футер выводили?
По пути catalog/veiw/javascript уже есть файл subscribe.js вот он Код: $(document).ready(function () { $('.subscribe-custom-position').each(function () { var subscribe_module = this; $.ajax({ url: 'index.php?route=module/subscribe', type: 'post', data: 'module='+$(subscribe_module).data('module'), success: function (data) { $(subscribe_module).html(data); } }); }); }); function addSubscribe(module) { var email = $('input[name="subscribe_email'+module+'"]').attr('value'); $.ajax({ url: 'index.php?route=module/subscribe/addSubscribe', type: 'post', dataType: 'json', data: 'email='+email+'&module='+module, success: function (data) { $('.subscribe_success'+module+', .error'+module).remove(); if (data['error']) { $('.subscribe'+module).after('<span class="error error'+module+'">'+data['error']+'</span>'); } if (data['success']) { $('.subscribe'+module).after('<span class="subscribe_success'+module+'">'+data['success']+'</span>'); $('input[name="subscribe_email'+module+'"]').attr('value', ''); } } }); }