JakubLW Posted June 14, 2018 Share Posted June 14, 2018 (edited) Próbuję dodać nowe pole "Rozmiarówka" dla każdego producenta, pole dodałem public function renderForm() { if (!($manufacturer = $this->loadObject(true))) { return; } $image = _PS_MANU_IMG_DIR_.$manufacturer->id.'.jpg'; $image_url = ImageManager::thumbnail($image, $this->table.'_'.(int)$manufacturer->id.'.'.$this->imageType, 350, $this->imageType, true, true); $image_size = file_exists($image) ? filesize($image) / 1000 : false; $this->fields_form = array( 'tinymce' => true, 'legend' => array( 'title' => $this->l('Manufacturers'), 'icon' => 'icon-certificate' ), 'input' => array( array( 'type' => 'text', 'label' => $this->l('Name'), 'name' => 'name', 'col' => 4, 'required' => true, 'hint' => $this->l('Invalid characters:').' <>;=#{}' ), array( 'type' => 'textarea', 'label' => $this->l('Short description'), 'name' => 'short_description', 'lang' => true, 'cols' => 60, 'rows' => 10, 'autoload_rte' => 'rte', //Enable TinyMCE editor for short description 'col' => 6, 'hint' => $this->l('Invalid characters:').' <>;=#{}' ), array( 'type' => 'textarea', 'label' => $this->l('Description'), 'name' => 'description', 'lang' => true, 'cols' => 60, 'rows' => 10, 'col' => 6, 'autoload_rte' => 'rte', //Enable TinyMCE editor for description 'hint' => $this->l('Invalid characters:').' <>;=#{}' ), array( 'type' => 'textarea', 'label' => $this->l('Rozmiarówka'), 'name' => 'rozmiarowka', 'lang' => true, 'cols' => 60, 'rows' => 10, 'col' => 6, 'autoload_rte' => 'rte', //Enable TinyMCE editor for description 'hint' => $this->l('Invalid characters:').' <>;=#{}' ), array( 'type' => 'file', 'label' => $this->l('Logo'), 'name' => 'logo', 'image' => $image_url ? $image_url : false, 'size' => $image_size, 'display_image' => true, 'col' => 6, 'hint' => $this->l('Upload a manufacturer logo from your computer.') ), array( 'type' => 'text', 'label' => $this->l('Meta title'), 'name' => 'meta_title', 'lang' => true, 'col' => 4, 'hint' => $this->l('Forbidden characters:').' <>;=#{}' ), array( 'type' => 'text', 'label' => $this->l('Meta description'), 'name' => 'meta_description', 'lang' => true, 'col' => 6, 'hint' => $this->l('Forbidden characters:').' <>;=#{}' ), array( 'type' => 'tags', 'label' => $this->l('Meta keywords'), 'name' => 'meta_keywords', 'lang' => true, 'col' => 6, 'hint' => array( $this->l('Forbidden characters:').' <>;=#{}', $this->l('To add "tags," click inside the field, write something, and then press "Enter."') ) ), array( 'type' => 'switch', 'label' => $this->l('Enable'), 'name' => 'active', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array( array( 'id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled') ), array( 'id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled') ) ) ) ) ); if (!($manufacturer = $this->loadObject(true))) { return; } if (Shop::isFeatureActive()) { $this->fields_form['input'][] = array( 'type' => 'shop', 'label' => $this->l('Shop association'), 'name' => 'checkBoxShopAsso', ); } $this->fields_form['submit'] = array( 'title' => $this->l('Save') ); foreach ($this->_languages as $language) { $this->fields_value['short_description_'.$language['id_lang']] = htmlentities(stripslashes($this->getFieldValue( $manufacturer, 'short_description', $language['id_lang'] )), ENT_COMPAT, 'UTF-8'); $this->fields_value['description_'.$language['id_lang']] = htmlentities(stripslashes($this->getFieldValue( $manufacturer, 'description', $language['id_lang'] )), ENT_COMPAT, 'UTF-8'); $this->fields_value['rozmiarowka'.$language['id_lang']] = htmlentities(stripslashes($this->getFieldValue( $manufacturer, 'rozmiarowka', $language['id_lang'] )), ENT_COMPAT, 'UTF-8'); } return parent::renderForm(); } Pole wyświetla się w panelu administratora, jednak po wpisaniu czegokolwiek nie zapisuje moich danych. Pole w bazie danych jest zrobione i nazywa się rozmiarówka: Co robię nie tak? Edited June 18, 2018 by JakubLW problem został rozwiązany (see edit history) Link to comment Share on other sites More sharing options...
0 atomek Posted June 14, 2018 Share Posted June 14, 2018 Musisz jeszcze zdefiniować pola w pliku /classes/Manufacturer.php 1 Link to comment Share on other sites More sharing options...
0 JakubLW Posted June 14, 2018 Author Share Posted June 14, 2018 Super, bardzo dziękuję, podpowiesz jeszcze tylko w jaki sposób wyświetlić zawartość kolumny "rozmiarowka" na stronie produktu? Link to comment Share on other sites More sharing options...
0 atomek Posted June 14, 2018 Share Posted June 14, 2018 spróbuj odwołać się w templatce product.tpl do $product_manufacturer->rozmiarowka (chyba to pole tak się u Ciebie nazywa) np: <div>{$product_manufacturer->rozmiarowka}</div> rozwiązanie dla PS 1.6 Link to comment Share on other sites More sharing options...
0 JakubLW Posted June 18, 2018 Author Share Posted June 18, 2018 Dziękuję, temat rozwiązany! Link to comment Share on other sites More sharing options...
Question
JakubLW
Próbuję dodać nowe pole "Rozmiarówka" dla każdego producenta, pole dodałem
public function renderForm() { if (!($manufacturer = $this->loadObject(true))) { return; } $image = _PS_MANU_IMG_DIR_.$manufacturer->id.'.jpg'; $image_url = ImageManager::thumbnail($image, $this->table.'_'.(int)$manufacturer->id.'.'.$this->imageType, 350, $this->imageType, true, true); $image_size = file_exists($image) ? filesize($image) / 1000 : false; $this->fields_form = array( 'tinymce' => true, 'legend' => array( 'title' => $this->l('Manufacturers'), 'icon' => 'icon-certificate' ), 'input' => array( array( 'type' => 'text', 'label' => $this->l('Name'), 'name' => 'name', 'col' => 4, 'required' => true, 'hint' => $this->l('Invalid characters:').' <>;=#{}' ), array( 'type' => 'textarea', 'label' => $this->l('Short description'), 'name' => 'short_description', 'lang' => true, 'cols' => 60, 'rows' => 10, 'autoload_rte' => 'rte', //Enable TinyMCE editor for short description 'col' => 6, 'hint' => $this->l('Invalid characters:').' <>;=#{}' ), array( 'type' => 'textarea', 'label' => $this->l('Description'), 'name' => 'description', 'lang' => true, 'cols' => 60, 'rows' => 10, 'col' => 6, 'autoload_rte' => 'rte', //Enable TinyMCE editor for description 'hint' => $this->l('Invalid characters:').' <>;=#{}' ), array( 'type' => 'textarea', 'label' => $this->l('Rozmiarówka'), 'name' => 'rozmiarowka', 'lang' => true, 'cols' => 60, 'rows' => 10, 'col' => 6, 'autoload_rte' => 'rte', //Enable TinyMCE editor for description 'hint' => $this->l('Invalid characters:').' <>;=#{}' ), array( 'type' => 'file', 'label' => $this->l('Logo'), 'name' => 'logo', 'image' => $image_url ? $image_url : false, 'size' => $image_size, 'display_image' => true, 'col' => 6, 'hint' => $this->l('Upload a manufacturer logo from your computer.') ), array( 'type' => 'text', 'label' => $this->l('Meta title'), 'name' => 'meta_title', 'lang' => true, 'col' => 4, 'hint' => $this->l('Forbidden characters:').' <>;=#{}' ), array( 'type' => 'text', 'label' => $this->l('Meta description'), 'name' => 'meta_description', 'lang' => true, 'col' => 6, 'hint' => $this->l('Forbidden characters:').' <>;=#{}' ), array( 'type' => 'tags', 'label' => $this->l('Meta keywords'), 'name' => 'meta_keywords', 'lang' => true, 'col' => 6, 'hint' => array( $this->l('Forbidden characters:').' <>;=#{}', $this->l('To add "tags," click inside the field, write something, and then press "Enter."') ) ), array( 'type' => 'switch', 'label' => $this->l('Enable'), 'name' => 'active', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array( array( 'id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled') ), array( 'id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled') ) ) ) ) ); if (!($manufacturer = $this->loadObject(true))) { return; } if (Shop::isFeatureActive()) { $this->fields_form['input'][] = array( 'type' => 'shop', 'label' => $this->l('Shop association'), 'name' => 'checkBoxShopAsso', ); } $this->fields_form['submit'] = array( 'title' => $this->l('Save') ); foreach ($this->_languages as $language) { $this->fields_value['short_description_'.$language['id_lang']] = htmlentities(stripslashes($this->getFieldValue( $manufacturer, 'short_description', $language['id_lang'] )), ENT_COMPAT, 'UTF-8'); $this->fields_value['description_'.$language['id_lang']] = htmlentities(stripslashes($this->getFieldValue( $manufacturer, 'description', $language['id_lang'] )), ENT_COMPAT, 'UTF-8'); $this->fields_value['rozmiarowka'.$language['id_lang']] = htmlentities(stripslashes($this->getFieldValue( $manufacturer, 'rozmiarowka', $language['id_lang'] )), ENT_COMPAT, 'UTF-8'); } return parent::renderForm(); }
Pole wyświetla się w panelu administratora, jednak po wpisaniu czegokolwiek nie zapisuje moich danych. Pole w bazie danych jest zrobione i nazywa się rozmiarówka:
Co robię nie tak?
problem został rozwiązany (see edit history)
Link to comment
Share on other sites
4 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now