Здравствуйте, подскажите модули всплывающего окна в магазин. Типа подписки что-то. Суть в том, чтобы клиент оставил свои контакты.
Popin Newsletter - всплывающее окно для подписки.
ещё надо заставить его работать.
Плюс хотелось бы чтоб попап вылазил сам при первом запуске страницы и держался на экране.
<?phpif (!defined('_PS_VERSION_')) exit;class Blocknewsletter extends Module{ public function __construct() { $this->name = 'blocknewsletter'; $this->tab = 'front_office_features'; $this->need_instance = 0; parent::__construct(); $this->displayName = $this->l('Newsletter block'); $this->description = $this->l('Adds a block for newsletter subscription.'); $this->confirmUninstall = $this->l('Are you sure you want to delete all your contacts ?'); $this->version = '1.4'; $this->author = 'PrestaShop'; $this->error = false; $this->valid = false; $this->_files = array( 'name' => array('newsletter_conf', 'newsletter_voucher'), 'ext' => array( 0 => 'html', 1 => 'txt' ) ); } public function install() { if (parent::install() == false OR $this->registerHook('leftColumn') == false OR $this->registerHook('header') == false) return false; return Db::getInstance()->Execute(' CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'newsletter` ( `id` int(6) NOT NULL AUTO_INCREMENT, `email` varchar(255) NOT NULL, `newsletter_date_add` DATETIME NULL, `ip_registration_newsletter` varchar(15) NOT NULL, `http_referer` VARCHAR(255) NULL, PRIMARY KEY(`id`) ) ENGINE='._MYSQL_ENGINE_.' default CHARSET=utf8'); } public function uninstall() { if (!parent::uninstall()) return false; return Db::getInstance()->Execute('DROP TABLE '._DB_PREFIX_.'newsletter'); } public function getContent() { $this->_html = '<h2>'.$this->displayName.'</h2>'; if (Tools::isSubmit('submitUpdate')) { if (isset($_POST['new_page']) AND Validate::isBool((int)($_POST['new_page']))) Configuration::updateValue('NW_CONFIRMATION_NEW_PAGE', $_POST['new_page']); if (isset($_POST['conf_email']) AND VAlidate::isBool((int)($_POST['conf_email']))) Configuration::updateValue('NW_CONFIRMATION_EMAIL', pSQL($_POST['conf_email'])); if (!empty($_POST['voucher']) AND !Validate::isDiscountName($_POST['voucher'])) $this->_html .= '<div class="alert">'.$this->l('Voucher code is invalid').'</div>'; else { Configuration::updateValue('NW_VOUCHER_CODE', pSQL($_POST['voucher'])); $this->_html .= '<div class="conf ok">'.$this->l('Updated').'</div>'; } } return $this->_displayForm(); } private function _displayForm() { $this->_html .= ' <form method="post" action="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'"> <fieldset> <legend><img src="'.$this->_path.'logo.gif" />'.$this->l('Settings').'</legend> <label>'.$this->l('Display configuration in a new page?').'</label> <div class="margin-form"> <input type="radio" name="new_page" value="1" '.(Configuration::get('NW_CONFIRMATION_NEW_PAGE') ? 'checked="checked" ' : '').'/>'.$this->l('yes').' <input type="radio" name="new_page" value="0" '.(!Configuration::get('NW_CONFIRMATION_NEW_PAGE') ? 'checked="checked" ' : '').'/>'.$this->l('no').' </div> <div class="clear"></div> <label>'.$this->l('Send confirmation e-mail after subscription?').'</label> <div class="margin-form"> <input type="radio" name="conf_email" value="1" '.(Configuration::get('NW_CONFIRMATION_EMAIL') ? 'checked="checked" ' : '').'/>'.$this->l('yes').' <input type="radio" name="conf_email" value="0" '.(!Configuration::get('NW_CONFIRMATION_EMAIL') ? 'checked="checked" ' : '').'/>'.$this->l('no').' </div> <div class="clear"></div> <label>'.$this->l('Welcome voucher code').'</label> <div class="margin-form"> <input type="text" name="voucher" value="'.Configuration::get('NW_VOUCHER_CODE').'" /> <p>'.$this->l('Leave blank for disabling').'</p> </div> <div class="margin-form clear pspace"><input type="submit" name="submitUpdate" value="'.$this->l('Update').'" class="button" /></div> </fieldset> </form>'; return $this->_html; } private function isNewsletterRegistered($customerEmail) { if (Db::getInstance()->getRow('SELECT `email` FROM '._DB_PREFIX_.'newsletter WHERE `email` = \''.pSQL($customerEmail).'\'')) return 1; if (!$registered = Db::getInstance()->getRow('SELECT `newsletter` FROM '._DB_PREFIX_.'customer WHERE `email` = \''.pSQL($customerEmail).'\'')) return -1; if ($registered['newsletter'] == '1') return 2; return 0; } private function newsletterRegistration() { if (empty($_POST['email']) OR !Validate::isEmail($_POST['email'])) return $this->error = $this->l('Invalid e-mail address'); /* Unsubscription */ elseif ($_POST['action'] == '1') { $registerStatus = $this->isNewsletterRegistered(pSQL($_POST['email'])); if ($registerStatus < 1) return $this->error = $this->l('E-mail address not registered'); /* If the user ins't a customer */ elseif ($registerStatus == 1) { if (!Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'newsletter WHERE `email` = \''.pSQL($_POST['email']).'\'')) return $this->error = $this->l('Error during unsubscription'); return $this->valid = $this->l('Unsubscription successful'); } /* If the user is a customer */ elseif ($registerStatus == 2) { if (!Db::getInstance()->Execute('UPDATE '._DB_PREFIX_.'customer SET `newsletter` = 0 WHERE `email` = \''.pSQL($_POST['email']).'\'')) return $this->error = $this->l('Error during unsubscription'); return $this->valid = $this->l('Unsubscription successful'); } } /* Subscription */ elseif ($_POST['action'] == '0') { $registerStatus = $this->isNewsletterRegistered(pSQL($_POST['email'])); if ($registerStatus > 0) return $this->error = $this->l('E-mail address already registered'); /* If the user ins't a customer */ elseif ($registerStatus == -1) { global $cookie; if (!Db::getInstance()->Execute('INSERT INTO '._DB_PREFIX_.'newsletter (email, newsletter_date_add, ip_registration_newsletter, http_referer) VALUES (\''.pSQL($_POST['email']).'\', NOW(), \''.pSQL(Tools::getRemoteAddr()).'\', (SELECT c.http_referer FROM '._DB_PREFIX_.'connections c WHERE c.id_guest = '.(int)($cookie->id_guest).' ORDER BY c.date_add DESC LIMIT 1))')) return $this->error = $this->l('Error during subscription'); $this->sendVoucher(pSQL($_POST['email'])); return $this->valid = $this->l('Subscription successful'); } /* If the user is a customer */ elseif ($registerStatus == 0) { if (!Db::getInstance()->Execute('UPDATE '._DB_PREFIX_.'customer SET `newsletter` = 1, newsletter_date_add = NOW(), `ip_registration_newsletter` = \''.pSQL(Tools::getRemoteAddr()).'\' WHERE `email` = \''.pSQL($_POST['email']).'\'')) return $this->error = $this->l('Error during subscription'); $this->sendVoucher(pSQL($_POST['email'])); return $this->valid = $this->l('Subscription successful'); } } } private function sendVoucher($email) { global $cookie; if ($discount = Configuration::get('NW_VOUCHER_CODE')) return Mail::Send((int)$cookie->id_lang, 'newsletter_voucher', Mail::l('Newsletter voucher', (int)$cookie->id_lang), array('{discount}' => $discount), $email, NULL, NULL, NULL, NULL, NULL, dirname(__FILE__).'/mails/'); return false; } function hookRightColumn($params) { return $this->hookLeftColumn($params); } function hookLeftColumn($params) { global $smarty; if (Tools::isSubmit('submitNewsletter')) { $this->newsletterRegistration(); if ($this->error) { $smarty->assign(array('color' => 'red', 'msg' => $this->error, 'nw_value' => isset($_POST['email']) ? pSQL($_POST['email']) : false, 'nw_error' => true, 'action' => $_POST['action'])); } elseif ($this->valid) { if (Configuration::get('NW_CONFIRMATION_EMAIL') AND isset($_POST['action']) AND (int)($_POST['action']) == 0) Mail::Send((int)$params['cookie']->id_lang, 'newsletter_conf', Mail::l('Newsletter confirmation', (int)$params['cookie']->id_lang), array(), pSQL($_POST['email']), NULL, NULL, NULL, NULL, NULL, dirname(__FILE__).'/mails/'); $smarty->assign(array('color' => 'green', 'msg' => $this->valid, 'nw_error' => false)); } } $smarty->assign('this_path', $this->_path); return $this->display(__FILE__, 'blocknewsletter.tpl'); } public function confirmation() { global $smarty; return $this->display(__FILE__, 'newsletter.tpl'); } public function externalNewsletter(/*$params*/) { return $this->hookLeftColumn($params); } function hookHeader($params) { Tools::addCSS(($this->_path).'blocknewsletter.css', 'all'); }}
<?phpif (!defined('_CAN_LOAD_FILES_')) exit;include(_PS_ROOT_DIR_ . _MODULE_DIR_ . 'blockcontacts/MContact.php');class blockcontacts extends Module { function __construct() { $this->name = 'blockcontacts'; $this->tab = 'front_office_features'; $this->version = '1.2'; parent::__construct(); $this->displayName = $this->l('Блок контактов'); $this->description = $this->l('Блок контактов (ICQ, Skype, MailAgent, E-Mail, Телефон, Yahoo, AIM)'); } function install() { if (!parent::install()OR !$this->registerHook('header') OR !$this->registerHook('footer') OR !Db::getInstance()->Execute(' CREATE TABLE ' . _DB_PREFIX_ . 'blockcontact (`id_contact` int(2) NOT NULL AUTO_INCREMENT, `contact` varchar(255) NOT NULL, type TINYINT(1) NOT NULL, PRIMARY KEY(`id_contact`)) ENGINE='._MYSQL_ENGINE_.' default CHARSET=utf8') ) return false; return true; } public function uninstall() { if (!parent::uninstall() OR !Db::getInstance()->Execute('DROP TABLE `' . _DB_PREFIX_ . 'blockcontact`')) return false; return true; } public function getContent() { $output = '<h2>' . $this->displayName . '</h2>'; if (Tools::isSubmit('submitContactAdd')) { $this->_clearBlockcontactsCache(); $contact = new MContact(); $contact->contact = Tools::GetValue('contact'); $contact->type = Tools::GetValue('type'); if ($contact->add()) $output .= '<div class="conf confirm"><img src="../img/admin/ok.gif" alt="' . $this->l('Добавлен') . '" />' . $this->l('Добавлен') . '</div>'; else $output .= '<div class="conf confirm"><img src="../img/admin/ok.gif" alt="' . $this->l('Ошибка') . '" />' . $this->l('Ошибка') . '</div>'; } elseif (Tools::isSubmit('submitContactUpdate')) { $this->_clearBlockcontactsCache(); $contact = new MContact(Tools::GetValue('id')); $contact->contact = Tools::GetValue('contact'); $contact->type = Tools::GetValue('type'); if ($contact->update()) $output .= '<div class="conf confirm"><img src="../img/admin/ok.gif" alt="' . $this->l('Обновлен') . '" />' . $this->l('Обновлен') . '</div>'; else $output .= '<div class="conf confirm"><img src="../img/admin/ok.gif" alt="' . $this->l('Ошибка') . '" />' . $this->l('Ошибка') . '</div>'; } elseif (Tools::isSubmit('submitContactDelete')) { $this->_clearBlockcontactsCache(); $contact = new MContact(Tools::GetValue('id')); if ($contact->delete()) $output .= '<div class="conf confirm"><img src="../img/admin/ok.gif" alt="' . $this->l('Удален') . '" />' . $this->l('Удален') . '</div>'; else $output .= '<div class="conf confirm"><img src="../img/admin/ok.gif" alt="' . $this->l('Ошибка') . '" />' . $this->l('Ошибка') . '</div>'; } return $output . $this->_displayForm() . $this->_list(); } private function _displayForm() {[quote][code] $html = ' <fieldset> <legend>' . $this->l('Добавить контакт') . '</legend> <form method="post" action="' . $_SERVER['REQUEST_URI'] . '"> <label>' . $this->l('Контакт:') . '</label> <div class="margin-form"> <div id="text" style="float: left;"> <input type="text" name="contact" id="contact" value="' . Tools::GetValue('contact') . '" /><sup> *</sup> </div> <div class="clear"></div> </div> <label>' . $this->l('Тип контакта:') . '</label> <div class="margin-form"> <select name="type" id="type"> <option value="0">Text</option> <option value="1">ICQ</option> <option value="2">Skype</option> <option value="3">MailAgent</option> <option value="4">E-Mail</option> <option value="5">Phone</option> <option value="6">Yahoo</option> <option value="7">AIM</option> </select> </div> <div class="margin-form"> <input type="hidden" name="id" id="id" value="' . Tools::GetValue('id') . '" /> <input type="submit" class="button" name="submitContactAdd" value="' . $this->l('Добавить контакт') . '" /> <input type="submit" class="button disable" name="submitContactUpdate" value="' . $this->l('Редактировать контакт') . '" disabled="disbaled" id="submitContactUpdate" /> </div> </form> </fieldset> '; return $html; } private function _clearBlockcontactsCache() { $this->_clearCache('blockcontacts.tpl'); Tools::restoreCacheSettings(); } public function hookHeader() { Tools::addJS(($this->_path) . 'js/blockcontacts.js'); Tools::addCSS(($this->_path) . 'css/blockcontacts.css', 'all'); } function hookRightColumn($params) { global $smarty; Tools::enableCache(); if (!$this->isCached('blockcontacts.tpl')) { $smarty->assign('contacts', MContact::getContacts()); } $smarty->cache_lifetime = 31536000; $display = $this->display(__FILE__, 'blockcontacts.tpl'); Tools::restoreCacheSettings(); return $display; } function hookFooter($params) { global $smarty; $smarty->assign('extended', true); return $this->hookRightColumn($params); } private function _list() { $links = MContact::getContacts(); $html = ''; global $currentIndex, $adminObj; $languages = Language::getLanguages(); if ($links) { $html .= '<script type="text/javascript" src="' . $this->_path . 'blocklink.js"></script> <script type="text/javascript"> var currentUrl = \'' . $currentIndex . '&configure=' . $this->name . '\'; var token=\'' . $adminObj->token . '\'; var links = new Array();'; foreach ($links AS $link) { $html .= 'links[' . $link['id_contact'] . '] = new Array(\'' . addslashes($link['contact']) . '\', ' . $link['type']; $html .= ');'; } $html .= '</script>'; } $html .= ' <h3 class="blue space">' . $this->l('Список контактов') . '</h3> <table class="table"> <tr> <th>' . $this->l('ID') . '</th> <th>' . $this->l('Контакт') . '</th> <th>' . $this->l('Тип') . '</th> <th>' . $this->l('Действие') . '</th> </tr>'; if (!$links) $html .= ' <tr> <td colspan="3">' . $this->l('Контакты отсутствуют') . '</td> </tr>'; else foreach ($links AS $link) $html .= ' <tr> <td>' . $link['id_contact'] . '</td> <td>' . $link['contact'] . '</td> <td>' . $link['type'] . '</td> <td> <img src="../img/admin/edit.gif" alt="" title="" onclick="linkEdition(' . $link['id_contact'] . ')" style="cursor: pointer" /> <img src="../img/admin/delete.gif" alt="" title="" onclick="linkDeletion(' . $link['id_contact'] . ')" style="cursor: pointer" /> </td> </tr>'; $html .= ' </table>'; return $html; }}?>
И на таком форуме просто необходим тег спойлера. Не очень приятно листать весь код я думаю)