IT City Posted October 5, 2022 Share Posted October 5, 2022 Hello, I want to create the ability to add elements to the header. Multiple items, I don't want to fix the quantity, I want to make it possible to add new items, how can I do that? Look example, i be thankful for any your idea. Link to comment Share on other sites More sharing options...
ps8modules Posted October 6, 2022 Share Posted October 6, 2022 (edited) This is done by creating your own tables in the database. For example, the ps_custom_header table and the ps_custom_header_lang table. Next, you can create a configuration form and a list of saved forms in the module. And for that you will create your own tpl template and load into it a field saved from the database for a certain language. I already gave you the link to the developer help in another post. Find HelperForm and HelperList. Edited October 6, 2022 by 4you.software (see edit history) 1 Link to comment Share on other sites More sharing options...
ps8modules Posted October 6, 2022 Share Posted October 6, 2022 (edited) Prestashop more advanced example symphony modules: https://github.com/PrestaShop/example-modules Edited October 6, 2022 by 4you.software (see edit history) Link to comment Share on other sites More sharing options...
IT City Posted October 6, 2022 Author Share Posted October 6, 2022 52 minutes ago, 4you.software said: Prestashop example modules: https://github.com/PrestaShop/example-modules Ok, thanks, i have seen the modules but any one not working in my version prestashop 1.7.8.7 Link to comment Share on other sites More sharing options...
ps8modules Posted October 6, 2022 Share Posted October 6, 2022 (edited) And please, what do you not understand about that? How to make a form and how to make a list of saved data? You need to insert some of your code here that you have already programmed. Edited October 6, 2022 by 4you.software (see edit history) 1 Link to comment Share on other sites More sharing options...
IT City Posted October 6, 2022 Author Share Posted October 6, 2022 Thank you for your attention, for a beginner this is an invaluable help. I now understood my mistakes, I realized that I am using some functionality from prestashop 1.6. Now I managed to display the contents of the module, on the main page in the DisplayNav1 hook Next, I will try to create a table in the database and learn how to work with it, I assume that I should create my own methods for working with the database in the main module file. Link to comment Share on other sites More sharing options...
ps8modules Posted October 6, 2022 Share Posted October 6, 2022 Yes 🙃 Add functions for installing and uninstalling database tables to the install and uninstall sections. E.g. 1. create folder in your project ./my_module/sql 2. add two files install.sql and unistal.sql 3. add const path to your module and function const INSTALL_SQL_FILE = 'install.sql'; const UNINSTALL_SQL_FILE = 'uninstall.sql'; public function __construct(Module $module = null, $context) { ..... } public function install() { $this->changeDatabase(self::INSTALL_SQL_FILE); .... if (!parent::install()) return false; return true; } public function uninstall() { $this->changeDatabase(self::UNINSTALL_SQL_FILE); .... if (!parent::uninstall()) return false; return true; } public function changeDatabase($file) { if (!file_exists(_PS_MODULE_DIR_.$this->moduleName.'/sql/'.$file)) { return false; } elseif (!$sql = file_get_contents(_PS_MODULE_DIR_.$this->moduleName.'/sql/'.$file)) { return false; } elseif (trim($sql) == '') { return true; } foreach ($sql as $query) { if ($query) { if (!Db::getInstance()->execute(trim($query))) { return false; } } } return true; } 1 Link to comment Share on other sites More sharing options...
IT City Posted October 8, 2022 Author Share Posted October 8, 2022 (edited) On 10/3/2022 at 5:27 PM, 4you.software said: I gladly helped 😉 Hello, tell me pleaseWhy when I display my module in a hook, it has a parent element with <a> tagThis tag is apparently generated automatically Edited October 8, 2022 by IT City (see edit history) Link to comment Share on other sites More sharing options...
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