Jump to content


  • Content count

  • Joined

  • Last visited

  1. Call Ajax not working

    Hello, I've created a custom form with star ratings. I am using ajax to send the form, but ajax not working. I do not receive errors and the status is OK: 200.Where am I doing wrong? This is the structure of the tpl file <div class="starrr" id="rating-comment"></div> <div id="commentFormBody"> <textarea id="comment" rows="10" cols="50"></textarea> </div> </div> <div id="commentSubmitButton"> <input type="submit" id="submit" value="submit" /> </div> </div> <!-------- STAR RATING --------> <script type="text/javascript"> {literal} var rating; $('#rating-comment').starrr({ change: function(e, value){ rating = value; if (value) { $(".your-choice-was").show(); $(".choice").text(value); } else { $(".your-choice-was").hide(); } } }); <!-------- AJAX SUBMIT ------> $('#submit').click(function() { var comment = $('#comment').val(); var baseDIR = 'http://localhost:8080/shop/' $.ajax({ url: baseDIR + 'modules/mymodule/controllers/front/save.php', type: 'POST', data: { comment: comment, rating: rating, ajax: true, }, success: function(status) { .................................... }); }); This is the php file <?php if (!defined('_PS_VERSION_')) exit; class MymoduleSaveModuleFrontController extends ModuleFrontController { public function initContent() { parent::initContent(); $rating = (int)Tools::getValue('rating'); $comment = trim(Tools::getValue('comment')); if(!empty($comment)) { Db::getInstance()->insert('comments', array( 'rating' => $rating, 'comment' => $comment, )); } $this->setTemplate('save.tpl'); } } Thank you, I'm sorry if I'm presenting the problem here
  2. Call ajax front controller not working

    Thank you for answering me, but I can not understand how I should do it. Could you give me, if possible, an example?
  3. Hello, I created a personal comment form with star ratings. I'm using ajax to send the form, the comment is inserted in the db, but the value of the evaluation is 0. The problem I believe is in the Tools: getValue ('rating') method: it does not receive the value of the evaluation. This is code: <div class="starrr" id="rating-comment"/></div> <form action=''> <input type="submit" id="submit" value="" /> <textarea id="comment" rows="10" cols="50"></textarea> </form> <script type="text/javascript"> {literal} var rating; $('#rating-comment').starrr({ change: function(e, value){ rating = value; ................................................... }); $('#submit').click(function() { var comment = $('#comment').val(); $.ajax({ url: baseDIR + 'modules/mymodule/controllers/front/save.php', type: 'POST', data: {comment: comment, rating: rating}, ................... ........ }); }); {/literal} </script> All this is in a tpl file class MymoduleSaveModuleFrontController extends ModuleFrontController { public function initContent() { parent::initContent(); $rating = (int)Tools::getValue('rating'); $comment = trim(Tools::getValue('comment')); thank you.
  4. Hello, I created a module that I placed in the right column of the homepage with an input type text, two buttons and success message: the first Submit and the other Back . The second button, Back does not work. I'm using, in the hookLeftColumn ($params) method, Tools: redirect ('http://localhost:8080/…./’../) to go back to the homepage and in the tpl file this line <a href = "{$url}" class = "btn btn-default" = "button"> Back </a> Please can you help me understand which instructions should I use? Thank you This is the hookLeftColumn method public function hookLeftColumn($params) { $this->smarty->assign(array( 'url' => Tools:redirect(‘http://localhost:8080/…./…/’) )); //code } This is the file tpl <div class="form-group"> <a href="{$url}" class="btn btn-default" role="button">Back</a> </div>
  5. Hello, I created a small form front office with an input field and a button. I'm trying to update the value my friend in the configuration table with the value entered in my input field. I tried these instructions, but the value is not updated. Where am I doing wrong? This is the coide of the myfirstmodule.php file that should update the text my friend public function changeValue( { $result = isset($_POST['text']) ? $_POST '[text'] : ””; Configuration::updateValue('MYMODULE_NAME', $result); } Thank you!
  6. Hello, can you help me to understand how to display all the categories on the back office page? In the categories page I only see the woman category, which corresponds to the top menu item on the homepage. The others: clothes and t-shirts are not displayed.
  7. Add CSS Custom

    I do not have a custom module, but I'm working on default blockcategories.css. I would not like to edit the blockcategories.ccs file, but I created a cutsom css file in the path indicated in the first post. Thanks to your answer I hope to have you sorted it out like this: First I put the line in red in the file below, then I added the link highlighted in blue. Categorycontroller.php public function setMedia() { parent::setMedia(); if (!$this->useMobileTheme()) { //TODO : check why cluetip css is include without js file $this->addCSS(array( _THEME_CSS_DIR_.'scenes.css' => 'all', _THEME_CSS_DIR_.'category.css' => 'all', _THEME_CSS_DIR_.'product_list.css' => 'all', _THEME_CSS_DIR_.'custom.css' => 'all', )); } Header.tpl {if isset($css_files)} {foreach from=$css_files key=css_uri item=media} {if $css_uri == 'lteIE9'} <!--[if lte IE 9]> {foreach from=$css_files[$css_uri] key=css_uriie9 item=mediaie9} <link rel="stylesheet" href="{$css_uriie9|escape:'html':'UTF-8'}" type="text/css" media="{$mediaie9|escape:'html':'UTF-8'}" /> {/foreach} <![endif]--> {else} <link rel="stylesheet" href="{$css_uri|escape:'html':'UTF-8'}" type="text/css" media="{$media|escape:'html':'UTF-8'}" /> <link rel="stylesheet" href="{$css_dir}custom.css" type="text/css" media="{$media}" /> {/if} {/foreach} I tried to make changes and work. Is this the correct procedure? Otherwise, following your answer, if I had a personal module, entering the blue line in the public function hookHeader () class, would the procedure be equally obscure? File blockcategories.php public function hookHeader() { $this->context->controller>addJS(_THEME_JS_DIR_.'tools/treeManagement.js'); $this->context->controller->addCSS(($this->_path).'blockcategories.css', 'all'); $this->context->Controller->addCSS($this->_ path'style.css', 'all'); } Bye.
  8. Add CSS Custom

    Hello everybody, I would need help adding a custom css file. I have created this path in the css folder: themes /mytheme /css /modules / mystyle /style.css. Which controller should I add the instruction below highlighted to change the left column block in the homepage? $this->context->controller->addCSS($this->_path'view/css/style.css','all') Thank you. Bye P.S. I use the prestashop version 1.6
  9. Custom CMS block

    Please help me with a screenshot. Thank you Bye
  10. Custom CMS block

    Thanks for the answer but my problem remains. These are the steps taken: 1) In the search box under module list I wrote CMS block 2) After I clicked on configure of the Custom CMS information block and added two new blocks. Then I clicked on save. 3) I refreshed the page but the blocks don’t appear in the Custom CMS information block under the blocks of the homepage. Why? How to view them? Thank you Bye P.S. Sorry i do not know how to attach files in the answers
  11. Custom CMS block

    Hello everyone, can you help me, please, to understand how to visualize Custom CMS Block in the CMSinfo_ block of the default theme in the homepage? I attach the file with the image where to insert the CMS block. Thank you. Bye.
  12. Ripristina tema di default

    Ciao a tutti i ragazzi del forum, da qualche giorno ho un problema che non riesco a risolvere: come prova ho installato un template ed è andato tutto bene. Poi, sempre come prova volevo ripristinare il tema di default. Ho provato a cliccare, andando su preferenza -> temi, sul template di default ma quando aggiorna la pagina rimane sempre il nuovo template con qualche blocco del template di default. Potete aiutarmi? Grazie Saluti a tutti