Jump to content

Skayfer

Members
  • Posts

    73
  • Joined

  • Last visited

1 Follower

Profile Information

  • First Name
    Andrzej
  • Last Name
    Sala

Recent Profile Visitors

186 profile views

Skayfer's Achievements

Newbie

Newbie (1/14)

0

Reputation

2

Community Answers

  1. Hi, I am working with my simple module and i have next problem, that i can't understand. In module config page i have to forms. First display something from db in inputs and works great. When i change something in input and not click save (submit this form), change wouldn't be save in db, when i click save all inputs are update, great. But in second form, that i use to add new rows in db is problem. When i am in new tab in this config page and realod my page nothing happens. But when i only once type something to inputs second form, click this submit, it looks like vars are not cleared. Now if i reload page 10 times i will have 10 new field, although i don't click submit. code from get Content function: $new_field_title = null; $new_field_value = null; if (Tools::isSubmit('add_new_field')){ $new_field_title = strval(Tools::getValue('new-field-title')); $new_field_value = strval(Tools::getValue('new-field-value')); if( !$new_field_value || empty($new_field_value) || !Validate::isGenericName($new_field_value) ||!$new_field_title || empty($new_field_title) || !Validate::isGenericName($new_field_title) ){ } else{ $sql = "INSERT INTO "._DB_PREFIX_."fields (title, value) VALUES ('".$new_field_title."','".$new_field_value."')"; Db::getInstance()->Execute($sql); } }
  2. Problem solved. I just forgot add " method="post" " to my form tag.
  3. Any idea ? I can make onclick event to button and call ajax function, which can execute php code in another file, but maybe is more correct solution.
  4. It isn't necesssary, but i need solution for call execution code in module php and now is only method what i know that give me this functionality.
  5. I am creating my new module. Now i have problem. In getContent function i need to use a few times 'Tools::isSubmit', beacuse settings page of my module have a few forms. But when i add next 'Tools::isSubmit', after click i am redirect to main dashboard page. Can i use a lot of that tool ? PS. If i good think, isSubmit let only make action (execute code), when i click input-submit. Is possible use this method to click on another buttons ? Or maybe You know another method that can me help ? Thanks for answers.
  6. Witam, Ostatnio tworzę na własne potrzeby pewien moduł. Sprawa wygląda tak, że mam funkcje displayForm, generującą pewien formularz. Ilość pól input jest dynamiczna i zależy od liczby znalezionych specyficznych wpisó w bazie. Chciałem teraz dodać sobie przycisk, za pomocą którego mógłbym tworzyć nowy wpis w bazie po kliknięciu. Próbowałem w displayForm dodać tablice buttons i jako href użyć nazwy funkcji, ale wygląda na to, że kod wywołuje się natychmiast, przy generowaniu formularza, a nie przy kliknięciu. Macie jakieś pomysły ? Ewentualnie zrobie sobie pliczek js, który dopisze mi do tego buttona atrybut "onClick" i kolejny wpis w bazie stworze sobie za pomocą ajax i funkcji php w osobnym pliku, ale nie wiem czy jest to obecnie poprawny sposób. PS. Jest sposób na dodanie pliku js do panelu konfiguracyjnego specyficznego modułu ?
  7. I too need answer for this question. Block layered use links, but i can't modify this link.
  8. Udało Ci się jakoś rozwiązać ten problem ? Mam podobny problem, w pewnych zmiennych mam id kilku produktów i chciałbym je wyświetlić w różnych miejscach szablonu. Potrzebowałbym teraz pobrać jakoś zdjęcie (w określonym rozmiarze), tytuł i cenę.
  9. Hi, I create my first module and i got stuck at this moment. I have default function display form. You probably know that there is 1'st level - main array, 2'nd level array with legend, submit, title and 3'th level array, for example with specific input settings. I have idea to dynamic get data from database to inputs. This part work good, but i have problem with dynamic generate inputs (3'th level array). I try use inside for loop or foreach, but it is forbidden by syntax. I generate my 3th level array outside main array and i can do this: 'input' => array( $nowy_array[1] ), , but i dont know add dynamic. I try add array without index and add array with pirnt_r, but it doesn't work. Thanks for answers
  10. I resolve my problem with https://www.prestashop.com/forums/topic/156171-new-global-var/ , but i add modification. Cart expert not add global to first declaration of var. I test it and i must add global. In step for other: 1. Outside main class i execute my code, declare "global $var", and assign result to "$var". 2. In each function in i want use this var, i must declare "global $var" and i can use "$var"
  11. Can anyone help ? Maybe i can use only context object ? It has this same functionality as gloabel var ?
  12. Hi, I write my module in which i have main class with a lot of fucntions. In almost every function i use var with number of result row: $sql = "SELECT value FROM ps_configuration WHERE name LIKE '%MY_VALUE%'"; $result = Db::getInstance()->ExecuteS($sql); $liczba_wierszy = DB::getInstance()->NumRows($result); It works ok, but i would like write this module better, i dont want duplicate this code. I would like declare var $liczba_wierszy in one function and can use it in other functions in my module. It is possible ? Thanks for answers
×
×
  • Create New...