table = 'guide_post'; $this->identifier = 'id_guide_post'; $this->className = 'GuidePost'; $this->lang = true; $this->edit = true; $this->view = true; $this->delete = true; $this->identifiersDnd['id_guide_post'] = 'id_guide_post'; parent::__construct(); } protected function _displayViewLink($token = null, $id) { $_cacheLang['View'] = $this->l('View'); echo ' '.$_cacheLang['View'].''; } public function postProcess() { global $cookie, $currentIndex; $this->fieldsDisplay = array( 'id_guide_post' => array( 'title' => $this->l('ID'), 'align' => 'center', 'width' => 25 ), 'name' => array( 'title' => $this->l('Category'), 'width' => 200, ), 'link_rewrite' => array( 'title' => $this->l('URL'), 'width' => 200 ), 'meta_title' => array( 'title' => $this->l('Title'), 'width' => 300 ), 'active' => array( 'title' => $this->l('Enabled'), 'width' => 25, 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false ) ); $this->_select = 'a.`position`, gcl.`name`, a.`id_guide_category` '; $this->_join = ' LEFT JOIN `'._DB_PREFIX_.'guide_category` gc ON gc.`id_guide_category` = a.`id_guide_category` LEFT JOIN `'._DB_PREFIX_.'guide_category_lang` gcl ON (gcl.`id_guide_category` = gc.`id_guide_category` AND gcl.`id_lang` = '.(int)($cookie->id_lang).')'; if (Tools::getIsset('id_guide_category')) { $this->fieldsDisplay['position'] = array( 'title' => $this->l('Position'), 'width' => 40, 'filter_key' => 'position', 'align' => 'center', 'position' => 'position' ); $this->_where = ' AND a.`id_guide_category`='.(int)Tools::getValue('id_guide_category'); $currentIndex.= '&id_guide_category='.(int)Tools::getValue('id_guide_category'); } parent::postProcess(); } public function displayList() { $this->_orderBy = 'position'; parent::displayList(); } public function displayForm($token = NULL) { global $currentIndex, $cookie, $smarty; parent::displayForm(); if (!($obj = $this->loadObject(true))) return; $langs = Language::getLanguages(false); $form = new FormBuilder('AdminGuidePosts', $this->table, 'id_guide_post', 'Add'); $this->fieldsForm = array( 'id_guide_category' => array( 'title' => $this->l('Catégorie du guide'), 'type' => 'select', 'options_raw' => GuideCategory::findCategoriesTree($cookie->id_lang), 'options_map' => ['id_guide_category', 'name', 'level'], 'initial_value' => $obj->id_guide_category ), 'meta_title' => array( 'title' => $this->l('Title (META)'), 'type' => 'text', 'translatable' => true, 'attrs' => [ 'onkeyup' => "copyField2friendlyURL('meta_title', 'link_rewrite');" ] ), 'meta_description' => array( 'title' => $this->l('Description (META)'), 'type' => 'textarea', 'translatable' => true, ), 'link_rewrite' => array( 'title' => $this->l('Simplified URL'), 'type' => 'text', 'required' => true, ), 'content' => array( 'title' => $this->l('Contenu de la page'), 'type' => 'textarea_tinymce', 'translatable' => true ), 'active' => array( 'title' => $this->l('Displayed'), 'type' => 'yesno', 'required' => true, ), ); $form->setTitle($this->l('Purchase guide page')); $form->setFields($this->fieldsForm); $form->setSubmitButton($this->l('Save')); $form->display($smarty, $langs, $obj); } }