I am new to Joomla, I want to know how the Joomla controller transmits data for model, controller and controller . Although it may be a silly question, I actually tried to find the answer. I hope I can get some help from the Stackworflow family.
In the controller, the user chooses the scene variable and determines which need to use these experiments . It then sets the scene to use, then calls the model to get the necessary data to the scene and then passes tmpl to display it.
Below it's a simple setup how all of this works together:
Component /com_test/controller.php
Class TestController JController Expands the {// default view function display () {// variable becomes some_var if it was posted or passed to GET $ var = JRequest :: getVar ('some_var'); // sets some footage html.php $ view = & amp; $ This- & gt; GetView ('some views', 'html'); // Set the template for some view.php $ viewLayout = JRequest :: getVar ('tmpl', 'someviewtmpl'); // Assigns the correct model (someview.php) for the view if $ ($ model = & amp; $ this-> MillModel ('some views')) $ view-> Setmodel ($ model, true); // See tmpl $ view-> See setLayout ($ visual layout) to see; // go to view and call the displaySomeView () method, also $ var variable $ view-> Pass in displaySomeView ($ var); }} component / com_test / views / someview / view.html.php
class EatViewSomeView JView extended {function displaySomeView ($ var) {// Controller $ Model = $ this- & gt; GetModel (); Get the model assigned to this view by using the // model we want to get the data tmpl $ data = $ model- & gt; GetSomeInfo ($ var); / Tmpl $ this- & gt; Specify the ideal result for viewing the assigner ('data', $ data); Call the parent class constructor to display // tmpl parent: display (); }} components / com_test / models / someview.php
class EatModelSomeView JModel provides // information from the database function getSomeInfo ($ var) Receive) {// database object $ db = $ this- & gt; GetDBO (); // This query is $ db-> Setclline ("select * FROM #__some_table where column = $ var"); // Results return to the form of orgade, which sets the results from each row returns from mysql $ db- & gt; LoadObjectList (); }} component / com_test / views / someview / tmpl / someviewtmpl.php
& Gt; Data as $ data) {// Each step here is a row, and we use data from each row for each call using the // data & quot; You can use [col_name] where the name [col_name] is in your db. You have the number of columns in the $ data-> Column_name; }
Comments
Post a Comment