Jump to content

nsuriac

Members
  • Posts

    12
  • Joined

  • Last visited

Profile Information

  • First Name
    Nil
  • Last Name
    Surià

Recent Profile Visitors

84 profile views

nsuriac's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Good morning, I've been trying to change the default image that appears in prestashop when no image is uploaded. I just changed the "es-default-home_default.jpg" files in the img folder. The fact is that it worked when the page is in Spanish, but when I change to french, prestashop looks for "fr-default-home_default.jpg", and this image don't exist anymore. How can I make prestashop to use always the link of the Spanish image? I will really appreciate your answers. Thank you!
  2. Hi Pascal! thank you a lot!!!! you really helped me so much! Awesome
  3. Hi Pascal! thank you a lot for your time and your fast answer. I understand how "!" (NOT) operator works. What I didn't know is that when you execute an "if" statement, it execute the condition and don't just compare if that condition is true or false. Then, I could not understand how was it possible that the "parent::install()" was executed if it was not ever called. Since I have a very bad English, I will try to explain it with an example: In the code above, the if statement condition "test()" will be converted to "true" Boolean since it's an string. Then the "!" (NOT) operator will convert that to "false" and the "echo "$nworking" will be ignored. If I execute the script nothing appear in the screen. I find it logical because I didn't executed the "test()" function. The if statement just check (compare) if it's true or false. Then, if "test()" is not executed, I can't understand how is it possible that "parent::install()" is executed and produce the installation if that function is never called! <?php $working = "it's working"; $nworking = "is not working"; function test() { echo "$working"; } if(!test()) {echo "$nworking";} ?> I really appreciate your answers and sorry if it's a stupid question. Thank you very much!
  4. Hello! I'm new in Prestashop development and I'm following a book called Prestashop Module development, from Fabien Serny. It's very interesting and helpful. However, there is something that I can't understand, and I thought that maybe someone here can help me. The problem is located in the "public function install()" where I call the "parent::install()". Lets see: The code above works on the code attached in the book, but not if i copy it on my code. public function install() { // Call install parent method if (!parent::install()) return false; // Execute module install SQL statements $sql_file = dirname(__FILE__).'/install/install.sql'; if (!$this->loadSQLFile($sql_file)) return false; // Register hooks if (!$this->registerHook('displayProductTabContent') || !$this->registerHook('displayBackOfficeHeader')) return false; // Preset configuration values Configuration::updateValue('MYMOD_GRADES', '1'); Configuration::updateValue('MYMOD_COMMENTS', '1'); // All went well! return true; } How can the first if statement ever return true if it's never called before? And the same for loadSQLFile and registerHook. I tried to do it in the way I think is more logical, and it works: public function install() { parent::install(); $sql_file = dirname(__FILE__).'/install/install.sql'; $this->loadSQLFile($sql_file); $this->registerHook('displayProductTabContent'); $this->registerHook('displayBackOfficeHeader'); Configuration::updateValue('MYMOD_GRADES', '1'); Configuration::updateValue('MYMOD_COMMENTS', '1'); return true; } So my questions are: 1. how can the firts code I posted work if the methods that apear inside the if statments arn't ever called? 2. why if I copy the code it dosn't work in my module if it does on the code from the book? There you go both full codes: <?php class MyModComments extends Module { public function __construct() { $this->name = 'mymodcomments'; $this->tab = 'front_office_features'; $this->version = '0.2'; $this->author = 'Fabien Serny'; $this->bootstrap = true; parent::__construct(); $this->displayName = $this->l('My Module of product comments'); $this->description = $this->l('With this module, your customers will be able to grade and comments your products.'); } public function install() { // Call install parent method if (!parent::install()) return false; // Execute module install SQL statements $sql_file = dirname(__FILE__).'/install/install.sql'; if (!$this->loadSQLFile($sql_file)) return false; // Register hooks if (!$this->registerHook('displayProductTabContent') || !$this->registerHook('displayBackOfficeHeader')) return false; // Preset configuration values Configuration::updateValue('MYMOD_GRADES', '1'); Configuration::updateValue('MYMOD_COMMENTS', '1'); // All went well! return true; } public function uninstall() { // Call uninstall parent method if (!parent::uninstall()) return false; // Execute module install SQL statements $sql_file = dirname(__FILE__).'/install/uninstall.sql'; if (!$this->loadSQLFile($sql_file)) return false; // Delete configuration values Configuration::deleteByName('MYMOD_GRADES'); Configuration::deleteByName('MYMOD_COMMENTS'); // All went well! return true; } public function loadSQLFile($sql_file) { // Get install SQL file content $sql_content = file_get_contents($sql_file); // Replace prefix and store SQL command in array $sql_content = str_replace('PREFIX_', _DB_PREFIX_, $sql_content); $sql_requests = preg_split("/;\s*[\r\n]+/", $sql_content); // Execute each SQL statement $result = true; foreach($sql_requests as $request) if (!empty($request)) $result &= Db::getInstance()->execute(trim($request)); // Return result return $result; } public function onClickOption($type, $href = false) { $confirm_reset = $this->l('Reseting this module will delete all comments from your database, are you sure you want to reset it ?'); $reset_callback = "return mymodcomments_reset('".addslashes($confirm_reset)."');"; $matchType = array( 'reset' => $reset_callback, 'delete' => "return confirm('Confirm delete?')", ); if (isset($matchType[$type])) return $matchType[$type]; return ''; } public function hookDisplayBackOfficeHeader($params) { // If we are not on section modules, we do not add JS file if (Tools::getValue('controller') != 'AdminModules') return ''; // Assign module mymodcomments base dir $this->context->smarty->assign('pc_base_dir', __PS_BASE_URI__.'modules/'.$this->name.'/'); // Display template return $this->display(__FILE__, 'displayBackOfficeHeader.tpl'); } public function processProductTabContent() { if (Tools::isSubmit('mymod_pc_submit_comment')) { $id_product = Tools::getValue('id_product'); $firstname = Tools::getValue('firstname'); $lastname = Tools::getValue('lastname'); $email = Tools::getValue('email'); $grade = Tools::getValue('grade'); $comment = Tools::getValue('comment'); $insert = array( 'id_product' => (int)$id_product, 'firstname' => pSQL($firstname), 'lastname' => pSQL($lastname), 'email' => pSQL($email), 'grade' => (int)$grade, 'comment' => pSQL($comment), 'date_add' => date('Y-m-d H:i:s'), ); Db::getInstance()->insert('mymod_comment', $insert); $this->context->smarty->assign('new_comment_posted', 'true'); } } public function assignProductTabContent() { $enable_grades = Configuration::get('MYMOD_GRADES'); $enable_comments = Configuration::get('MYMOD_COMMENTS'); $id_product = Tools::getValue('id_product'); $comments = Db::getInstance()->executeS(' SELECT * FROM `'._DB_PREFIX_.'mymod_comment` WHERE `id_product` = '.(int)$id_product); $this->context->controller->addCSS($this->_path.'views/css/star-rating.css', 'all'); $this->context->controller->addJS($this->_path.'views/js/star-rating.js'); $this->context->controller->addCSS($this->_path.'views/css/mymodcomments.css', 'all'); $this->context->controller->addJS($this->_path.'views/js/mymodcomments.js'); $this->context->smarty->assign('enable_grades', $enable_grades); $this->context->smarty->assign('enable_comments', $enable_comments); $this->context->smarty->assign('comments', $comments); } public function hookDisplayProductTabContent($params) { $this->processProductTabContent(); $this->assignProductTabContent(); return $this->display(__FILE__, 'displayProductTabContent.tpl'); } public function processConfiguration() { if (Tools::isSubmit('mymod_pc_form')) { $enable_grades = Tools::getValue('enable_grades'); $enable_comments = Tools::getValue('enable_comments'); Configuration::updateValue('MYMOD_GRADES', $enable_grades); Configuration::updateValue('MYMOD_COMMENTS', $enable_comments); $this->context->smarty->assign('confirmation', 'ok'); } } public function assignConfiguration() { $enable_grades = Configuration::get('MYMOD_GRADES'); $enable_comments = Configuration::get('MYMOD_COMMENTS'); $this->context->smarty->assign('enable_grades', $enable_grades); $this->context->smarty->assign('enable_comments', $enable_comments); } public function getContent() { $this->processConfiguration(); $this->assignConfiguration(); return $this->display(__FILE__, 'getContent.tpl'); } } <?php class MyModComments extends Module { public function __construct() { $this->name = 'mymodcomments'; $this->tab = 'front_office_features'; $this->version = '0.1'; $this->author = 'Nil Surià'; $this->bootstrap = true; parent::__construct(); $this->displayName = $this->l('My Module of product comments'); $this->description = $this->l('With this module, your customers will be able to grade and comments your products.'); } public function install() { if (!parent::install()) return false; $sql_file = dirname(__FILE__).'/install/install.sql'; if (!$this->loadSQLFile($sql_file)) return false; if (!$this->registerHook('displayProductTabContent') || !$this->registerHook('displayBackOfficeHeader')) return false; Configuration::updateValue('MYMOD_GRADES', '1'); Configuration::updateValue('MYMOD_COMMENTS', '1'); return true; } public function loadSQLFile($sql_file) { $sql_content = file_get_contents($sql_file); $sql_content = str_replace('PREFIX_', _DB_PREFIX_, $sql_content); $sql_requests = preg_split("/;\s*[\r\n]+/", $sql_content); $result = true; foreach($sql_requests as $request) if (!empty($request)) $result &= Db::getInstance()->execute(trim($request)); } public function processProductTabContent() { if (Tools::isSubmit('mymod_pc_submit_comment')) { $id_product = Tools::getValue('id_product'); $grade = Tools::getValue('grade'); $comment = Tools::getValue('comment'); $insert = array( 'id_product' => (int)$id_product, 'grade' => (int)$grade, 'comment' => pSQL($comment), 'date_add' => date('Y-m-d H:i:s'), ); Db::getInstance()->insert('mymod_comment', $insert); $this->context->smarty->assign('new_comment_posted', 'true'); } } public function assignProductTabContent() { $enable_grades = Configuration::get('MYMOD_GRADES'); $enable_comments = Configuration::get('MYMOD_COMMENTS'); $id_product = Tools::getValue('id_product'); $comments = Db::getInstance()->executeS(' SELECT * FROM `'._DB_PREFIX_.'mymod_comment` WHERE `id_product` = '.(int)$id_product); $this->context->controller->addCSS($this->_path.'views/css/star-rating.css', 'all'); $this->context->controller->addJS($this->_path.'views/js/star-rating.js'); $this->context->controller->addCSS($this->_path.'views/css/mymodcomments.css', 'all'); $this->context->controller->addJS($this->_path.'views/js/mymodcomments.js'); $this->context->smarty->assign('enable_grades', $enable_grades); $this->context->smarty->assign('enable_comments', $enable_comments); $this->context->smarty->assign('comments', $comments); } public function hookDisplayProductTabContent($params) { $this->processProductTabContent(); $this->assignProductTabContent(); return $this->display(__FILE__, 'displayProductTabContent.tpl'); } public function processConfiguration() { if (Tools::isSubmit('mymod_pc_form')) { $enable_grades = Tools::getValue('enable_grades'); $enable_comments = Tools::getValue('enable_comments'); Configuration::updateValue('MYMOD_GRADES', $enable_grades); Configuration::updateValue('MYMOD_COMMENTS', $enable_comments); $this->context->smarty->assign('confirmation', 'ok'); } } public function assignConfiguration() { $enable_grades = Configuration::get('MYMOD_GRADES'); $enable_comments = Configuration::get('MYMOD_COMMENTS'); $this->context->smarty->assign('enable_grades', $enable_grades); $this->context->smarty->assign('enable_comments', $enable_comments); } public function getContent() { $this->processConfiguration(); $this->assignConfiguration(); return $this->display(__FILE__, 'getContent.tpl'); } } If anyone had read up here it deserves a big applause. Thank you!
  5. another solution to controlle the height and width is to set useCSS to true in the jquery file. It worked for me. if (!!$.prototype.bxSlider) $('#homeslider').bxSlider({ useCSS: false, /*change this to true*/ maxSlides: 1, slideWidth: homeslider_width, infiniteLoop: homeslider_loop, hideControlOnEnd: true, pager: false, autoHover: true, auto: homeslider_loop, speed: parseInt(homeslider_speed), pause: homeslider_pause, controls: true });
  6. Hi Enrrique. Thank you for answering me. I'm sorry for not following the forum rules. I will read them carefully before my next post. About the environment, I'm working with a local server. I'm using UniserverZ. The modified theme is the default-bootstrap. As I said, I went back to se what part of the css was breaking the menu effect, and I found it was a delated "clear:both" in the file superfish-modified.css located in "C:\UniServer\www\prestashop\themes\default-bootstrap\css\modules\blocktopmenu\css". Then, my question was more about understanding how files are linked and how it exactly works in prestashop. As I could see in the code, the hover and menus effects are achieved by javascript and not by css. How is it possible that a change in the css affects the javascript? Otherwise, I have just seen that now on chrome inspector tool it appears that the rendered files are the .scss ones, located in "C:\UniServer\www\prestashop\themes\default-bootstrap\sass\modules\blocktopmenu\css", instead of the .css one mentioned before. Why this change? Definitely I got problems understanding how prestashop works. Any help will be very apreciated. I upload the screenshoot again:
  7. After reversing all chenges i did to se what was the change that produced the submenus and hover stop working, i realized its just when delating the clear:both; from .sf-contener. I did that to display the logo and the menu inline. why is it wrong? Thank you!
  8. Hello! i midified the global.css and the specific superflish-modified.css to change the menu position and with. After that, i realized that the links were not working and the hover efect also was broken. My question is why? i didnt changed any clases or even changed any .tpl file or .php. I been reading the blocktopmenu.php file and everything sems fine. I can't understant why the javascript is not doing it's job. Thats how the prestashop looks like: I will be very happy if anyone helps me! thank you!
  9. Hello! I finally found a really good guide that i would like to shere. http://www.daveegerton.com/prestashop-guides/Prestashop-Designers-Guide/Structure/File-Structure.html It seems very usefull. Hope it can also help to you!
  10. Hello! I also got problems understanding how prestashop works. In spite I read a lot about MVC and I got to understand it's idea, I can't understand how prestashop uses it. For example, in theory, .tpl files are the view, but CSS should also be a part of the view, right? I cant really get what .tpl does. Does it structure the content and then you can use css to give style to this structure? I've been trying to create a theme by modifying the default one, but for example i'm not able to change modules positions, and the css is very disperse... Could anyone give me some tips? i would be very grateful! thank you!
×
×
  • Create New...