CedGauche Posted September 11, 2019 Report Share Posted September 11, 2019 (edited) Good morning from germany, I've created a new module with a form. But how can I get the form values as a variable into the DataClass query. The module has these 3 files: TourenDataClass.php Touren.php touren.tpl queries without variables from the TourenDataClass.php are working in the touren.tpl. I'm quity new in php so I need advice Edited September 11, 2019 by CedGauche Quote Link to comment Share on other sites More sharing options...
LeonardIGO4036 Posted September 17, 2019 Report Share Posted September 17, 2019 On 9/11/2019 at 11:59 AM, CedGauche said: Good morning from germany, I've created a new module with a form. But how can I get the form values as a variable into the DataClass query. The module has these 3 files: TourenDataClass.php Touren.php touren.tpl queries without variables from the TourenDataClass.php are working in the touren.tpl. I'm quity new in php so I need advice Hello, greetings from India [Quick fix, change your file name to TourenData.class.php] Assuming you are asking how to get data into the DataClass, the answer to that would be "using SQL". Example: public static function GetTourenData() { // Getting all values from a table $sql = "SELECT * FROM `phpvms_tourendata`"; return DB::get_results($sql); } If you need to use a variable in the module, assuming that it is already establed (coded) in the DataClass (core/common) folder, all you'll have to do is to just assign a variable to display the value. Example: In ACARSData.class.php, you have a static function called "GetACARSData()" which returns an array. The idea is to get your static function inside TourenData.class.php to return some value. Once that is done, you can call that inside your module like this... Assuming we are coding in the public index function of your module, code this way $this->set('tourendata', TourenData::GetTourenData()); $this->render('touren.tpl'); So now, phpVMS is assigning the values of TourenData::GetTourenData() function into a variable called "$tourendata" which you can use in the template file. One more way I have seen people using this is, to set the data to the variable instead of using "this", Template::set('tourendata', TourenData::GetTourenData()); nevertheless, both methods work. Let me know if this was of any help, Regards, Leonard 1 Quote Link to comment Share on other sites More sharing options...
CedGauche Posted September 24, 2019 Author Report Share Posted September 24, 2019 Thank You Leonard, I will try it Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.