diff --git a/013-dynamicGet.md b/013-dynamicGet.md index 7d70aa6..9ebb980 100644 --- a/013-dynamicGet.md +++ b/013-dynamicGet.md @@ -1 +1,29 @@ -Hi [00:00:04](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h00m04s) We still working with Sermon distributor So I'm gonna use this preacher Which is a Get that I already have set up here I'll use that In our illustration So here we can see that I have This Back end [00:00:25](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h00m25s) View selected So It's been select nothing This is usually how it will look When you start So You'd look Select This Depending on which [00:00:39](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h00m39s) Area of the Backend you wanna get the data from You'd select Backend View Which is the Best way to do it I would say Then there is the Joomla Database option Would basically gives you the access to draw data from any other component installed that moment in the Joomla Website [00:01:01](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h01m01s) So if you select your Joomla Database You can select any Database That Is actually at that stage On your Database Installed And that means you can reach out to other components Through this dynamic get I'm gonna not do that [00:01:21](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h01m21s) In fact that's also an area which I haven't tested so well I You possibly might try to implement that And ran into some bugs And this stage I can't make any apologies for that since Really thing you should do is instead using Back end View Option Now [00:01:42](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h01m42s) You might say but why is the other option there Well it's because that's a feature we certainly want in the application right And so I'm busy working in that direction And busy Programming so did that feature will work without any problems In fact for the most part if you don't do very complex Mapping If you just do a simple Direct database fetch like that Are you be able to use this it won't give you an issue [00:02:09](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m09s) What it really is about these other Linked or Joint database structures That really would make it complex So And that might Cause problems I'm not 100% sure Obviously it did work But I haven't tested it well enough as well as I have tested the other part and that is this back-end view [00:02:32](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m32s) There is also the custom option Where you can just dump the whole Option of Using component builder to sort of write your Your your PHP for you And here you can add custom PHP it will add The methods data for you So this is a custom get option where you write the code [00:02:55](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m55s) Basically by hand Where is this option Write the code for you So You select the back-end view that you want to use again that back-end view Will be the the view that you connected to your component right So you need to type that you name in here and then select That package And it will load [00:03:20](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m20s) All the field names As a.id and a.asset id and a.name and allias and icon So these are all the fields inside of this view And I will load it and I'll put this as Asset ID Now again I would suggest you don't change that What you can do is you can take Out a row You feel ok I don't need that row [00:03:50](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m50s) Then you can Remove a row Like that And you can say I don't need the row I don't need these Way to there Basically that's all the data you might want And then you will know That this would be the variable name Of the data on When do When these get is used [00:04:13](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m13s) So that's the The basic part of setting up a Get I need to mention that you have get types as well now the get types have 4 of them There is the get item Which will get one item so that means from this preacher table It will get one item Then you got the get listQuery Which will get Multiple Items [00:04:41](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m41s) Ok so depending on how many items you want to get from the database you would select either get item or get list Then you get custom And then you got Get customs that plural And The difference between these two or four Is the get item Is what you will use only once per [00:05:04](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h05m04s) Per view So if you are building a custom admin view You will select a main get Either of a get item or either of get list But you can add multiple custom get item Or custom get items So You can see these as Other Methods that you're adding to the page but it's not the main method [00:05:30](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h05m30s) so you have main methods which are these a get item and get listquery Which by the way is the exact naming of the methods that will be used And then you got this custom get custom and get customs Which is really almost same as these two it's just that they are not Main There will only be another method in the model Which will bring data to the view So you can add as many custom Get custom and get customs [00:06:00](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m00s) Methods To your view as you like but you could only add one get item and you only add one get listquery Usually the way we would decide on this is that we would Say what is the main objective of The View What is the main dataset that we want to use in the view And that is what we will use the get list query and get item for Respectively [00:06:27](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m27s) So if the main purpose of The View It's a show preachers, a list of preachers I would use the get list query as the main Selection here Now you see that you have when you do a list query you have the option of adding pagination So Basically that would mean whether the data should only return a certain number Now Joomla has a global number there Which you set in the system administrative area under your Global settings [00:07:00](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h07m00s) let me show you that So you go to system Then Global configuration And then you see there is a default list limit This one here And That is what will be used as the amount That limits the data being returned to the page so it will only return at this stage 20 item [00:07:26](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h07m26s) If I set that pagination to yes And if I set it to no it will load all the data So yes would just load some of it And no will load all of the data so depends on what you wanna do if you wanna do an Ajax Well you wanna be sure that all the data is being loaded every time and you rather use JavaScript Set up pagination for yourself for your view Then that is why you would use the no switch most of the time you're just say yes And [00:08:00](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m00s) Joomla world Sorry component builder will automatically add the pagination code to the page It will also automatically add pagination code to the model And at the bottom of the page it will show a one two three pagination now possibly depending on The template you are using And the styles that are on the page Bootstrap is not on the page that one two three might possibly not look right and you will need to add styling to it [00:08:31](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m31s) component Builder doesn't know what style is on your page so they cannot make provision for all of that But it actually can load the pagination itself And it does Do that Ok Now here you have data and You can join this data to other database tables And now again here like with the main source You're able to select [00:08:57](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m57s) Joint Views From a table A view Table which is basically the views of the component Or just any database table And to one of the database tables I often Connect to these categories you see because component builder Integrates It's application If you add a category field To any View [00:09:22](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m22s) It dynamically set up a category for your component And integrates the category concept into your component so it writes all that code for you and basically the way that Joomla's own Applications like Article manager does it so it's using the same conventions So if you know how Joomla article manager is bringing categories into the articles Then that is the way your component is gonna do it as well And Here You can now select categories [00:09:54](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m54s) You can say These switches I'll Deal with When we come and look in More detail at this area And then you can model the data there And model I mean decide what you want to return you don't want to return everything from categories But the one I want to look at first is actually this joint view Table we'll come back to the DB option The joint view Table let you again select from any of the other views that is Part of your component [00:10:25](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m25s) And again you can select whether it should return a single row Or a List of rows Now when you say single row it means it's gonna literally join it To this other data set that you have as your main data or your main source It will just be another Item in the array And so that's why you can't use the name Name For example here [00:10:51](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m51s) It needs to have that That series underscore in front of it So that it doesn't clash with the other data set that possibly also has a value called name So again here if you selected you know let me just select Anything here Series You see that it will populate this area with all the fields that is in that View Then this as Button here [00:11:21](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m21s) Basically You can't use the same Alphabetic number twice in the whole In the whole query So So the whole get function can only use a once and then b once and then c once and then D So You need to make sure that the [00:11:40](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m40s) That these are set up that you can we'd made provision up to z z How many tables you can have Only in this area here and So Basically you would First decide whether this row Type what type of return it will be If you set it to multiple you see that these names automatically update [00:12:02](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m02s) Because now The way that the get method will Work Is it will create a new Method Which will get this data And add it into your item list Via this relationship so I'm adding the on field as the Dot a series that's where the ID is for the series [00:12:24](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m24s) And the joint field I'm using the C ID which is that one So that means in the main Database That is the a database There must be a field called series And it has the ID of the series And it corresponds to the ID in this list And if I wanted to return a multiple it means that The main database which is in that case a sermon Can be linked to multiple serieses But in the system we are working with here [00:12:56](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m56s) That is not possible you can only Connect a sermon to one series So that means it's certainly a single return Then it will immediately add this Series underscore in front of everything to insure doesn't clash with your a table That's What It's basically doing Again you can remove the fields you don't want but Please do not edit [00:13:18](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m18s) The string It possibly would make it break I wanted to be possible that you can change this name to anything you like And we are gonna try and do that eventually but for now it's still doesn't really like you doing that And it it in fact you can be changing it it will still write it this way in the code that's That's part of why I'm saying you shouldn't change it not because it will break something but because it will be ignored and you might expect something else than what it is actually doing So it still is gonna use this Implementation even if you change it [00:13:54](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m54s) But it will drop the fields you don't select so if you say I don't want these That Then it won't get those Fields and you will only have this data returned And again here you can have equal Not equal Equal or not And we also have in function That means [00:14:22](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m22s) if This joint value Sorry If this on field Is an array Then you can use the in function To make sure that it Actually looks whether the id in this That's the in function And again Remember when we started out I told you that you need to be willing to get your hands dirty [00:14:45](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m45s) Now This code If we go to the component itself I'll show you where it writes this code So Let me scroll down to the bottom here And let's see we're looking into sermon Preacher ID Now we'll still get to why it says preacher ID When we look at the filters and the where [00:15:06](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15m06s) but let us go to the code Now you can actually see I'm gonna refresh this page and then go to the code Ok so since this get is used in the front Of the component we will go to the front end and not to the admin area So we go to the front end Of sermon distributor And then we are Looking at the model right the get Dynamic get is used in the model to get the data [00:15:33](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15m33s) And we are looking at sermons let me just make sure of that Yes it's sermons Getting a list query and it's using pagination Getting all this So we're Looking at sermons Sermons on the Under the preacher ID so it should be this model I'll still show you the way that I know all that [00:16:02](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m02s) But just that I could get you into the code here You can see the main Method Which actually has this dot ID or the main Data set sorry not method data set It is written here So here you can see ID, acid ID name alias link types short description [00:16:26](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m26s) If you look at the UI it says the same things, alias, link type short description Icon preacher series category ID So this is where it writes it And it shows you where in the complier it's done that Then it sets up the Second one Series you see And Then You can also see it says series [00:16:50](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m50s) Equals c ID So series There is series Equals The c This table series ID And then it also tells you what it wants from c it wants the name and the alias and then it wants a series name that Changes it to series [00:17:12](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h17m12s) Since this is in the select Query this is one function there And So that array And Transposes to this array That is the way that you make use of Joomla's Database PPI So it has a thing called quote name [00:17:35](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h17m35s) Which you can pass to arrays And the first array being the actual Name of the Value which in this case is name and alias And the second array What you wanted to be once the query is completed So it links this into the the query One-by-one See all of those even the category one is linked in here And then [00:17:59](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h17m59s) It does a check whether there's an ID And if it exists it checks whether it's a string If it's a string it adds a quote And if it isn't if it's a number It just adds it directly and That is where Where the query is done And here basically return false if there is no ID And so we'll look at this area in a moment this is done [00:18:23](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h18m23s) To the filtering and the wear Ok So I just wanted to show how it adds this Preacher as well as series To the query if we Look at the back Open up here You see that series And preacher [00:18:41](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h18m41s) And statistics but statistics You see we select Multiple statistics Because for one sermon There can be multiple downloads right So there's multiple statistics Oh sorry not multiple downloads multiple files And per file there will be a a a number So if we look at how he does that [00:19:02](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h19m02s) It is first does the query and hearing get item It actually Adds a new function Called Get ID sermon statistics and with a With a random Key To ensure that it doesn't conflict with any other method on the page We had to add this random key here And it puts it into this variable and that something that you need to [00:19:27](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h19m27s) Come and look at And Possibly when we look at the the site Layout area as well as the tablets I'll be talking about this transition here again And the fact that you need to know That it is in this variable And I'm trying inside of your layouts and your site views and these things I'm trying to give you the correct name But it is not [00:19:51](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h19m51s) Water tight correctly Possibly you need to come and check this if it doesn't just work But again I'll explain that when we get there just that you know We're adding statistics into this variable through a method which is also on the page and we passing the ID Of of the sermon So if you look at UI This exactly what we're saying here We're saying Okay get statistics multiple [00:20:19](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h20m19s) so we Went to the left Can you can select any of these And then Use the main table dot ID Must be equal to e.sermon And then this is the only values I want to return From the e.sermon So the e.sermon is this value here okay o I'm saying a ID must equal is e.sermon [00:20:48](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h20m48s) And then if you look at the code It basically if we go to this function which should be just here there it is. It takes that ID And Places that next to e.sermon and puts into its place Basically also here's the two arrays what it What it is in the database and what it should be now And it checks whether executes, checks whether it's got any arrays or any values [00:21:17](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h21m17s) And then returns that is an object List And that then gets placed inside of this Space inside here Now you would see this area here Is actually custom scripting So if we go back to the dynamic get you see that there is a custom script area here If you click on that You'd see that there is Different switches [00:21:54](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h21m54s) You can select Get list query Or before getting the items After getting the items If you select after getting the items And you place any code there Then data gets dumped right after The initial items we've Received It will it will add that [00:22:14](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h22m14s) Code in there and then only return The items So that is why you can model the data Right there in the dynamic get You gonna write the code For the data After it's been get And you can check If I remove this Code here you'd see tells you that there is an array of items [00:22:33](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h22m33s) Where all values are And then I'm just saying I want to be sure that those items are set and that they are there Before I start doing it on each of them And so again here I'm using Some double You know the street bracket component helper functions to check whether the String is there So you can dump some nice PHP Even before getting the item you can add some filters or get list query [00:23:02](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h23m02s) Before the if you if this is model list If this is item You'd see that Then there's a different set of Switches is available And so it Adjusts to To the type of Query type up here Ok [00:23:19](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h23m19s) Coming back to this area Let's again look at the database table option Basically you see I selected category and it's a single row that's returned I called it b I joined it left and I said a Cat ID must be equal to b ID Which is the ID of the category And I only want The title And the alias So that is [00:23:44](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h23m44s) how we set that up I need a title in the alias And it returns that for us Then It links it in there and that's part of what you saw here when You looked at the query option here Basically the sixth section here Now let's look at the filters You see where we've a filter And a where and an ordering and setting of Globals [00:24:12](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h24m12s) now the setting of Globals if you have a value in this query That you possibly want to use in a custom query which isn't even Setup yet but you want you know I'm gonna need this value in the model Then you can through this Global option here You can set a global area now Again here you should maybe test it There is an option of using this and State [00:24:38](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h24m38s) there is the different type of Set types You can set the value to state or you can set the value to this And here you need to know key so So let's I wanna do the name Obviously in this case is not gonna work ideal Because you got more than one name So usually this Global function only functions well [00:25:01](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h25m01s) When you are returning a single Item so when you only do get item not get list query But you do get Item Then this make sense and then you can give it a name And it will add it to the global Scope of the method or the model rather Which you can access through other [00:25:24](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h25m24s) Model Methods Which are custom Methods Ok so that is setting the global The filtering You have a a list of possible filtering So Depending on what you wanna do You might select ID or user or access level or group or category [00:25:45](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h25m45s) or Tags or date Some of these are not really well formulated yet like date doesn't work that well yet But categories does user group access level user and ID does well You know this function variable works well and Array Array value repeatable value and other All those already work very well And you can already use them and Implement them Now the only way for you to really [00:26:15](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h26m15s) Know exactly how it works you need to know a little PHP and then you need to compile and go look in the code what it has done and where it's placed what And that Is Why I showed you that this is all set in the model Ok So currently We are saying we wanted to do a J request Get into here by ID [00:26:39](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h26m39s) So this is the get area that I added I look in The code it says State the key and it's this Here you see and we set it is a function variable So it doesn't change or adapt this at all And then says it must be equal to preacher So what we are doing since component builder doesn't know where the this variable is gonna be a string or integer That's why we have this function which first checks were that is string [00:27:08](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h27m08s) And then checks whether it's a number And related and builds up the query respectively You might feel that is too much and you're Possibly right But that is the only way I am implement it at this stage And getting more developers involved May possibly improve this long run Then you see there the Access Now we have a bunch of values that fire every time in a custom [00:27:39](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h27m39s) Dynamic get model And it is the these values And often times you you might need these values So instead of you Having to do custom scripting to get these values on the page We add these values dynamically every time So the user ID the group The authorised group the access level The app and then the input values Which by other URL or post is on the page [00:28:08](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h28m08s) And it tells you that it's been initiated so This is set to true so that if you have custom Methods Like this one get Preacher It's checks whether it's been set And if it has been set it doesn't set that again it can just use it But if it hasn't been set it sets it and also again sets it to true So [00:28:32](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h28m32s) variables Global variables Can then be used inside of the coaches like the global variable we spoke of earlier Ok so Out of that Global variable We are Actually accessing This levels And so it's this one here Which basically has the get authorized view levels Of the specific user [00:29:00](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h29m00s) That is now you know accessed this Model or the view that this model belongs to And if he is in these access levels So you remember that public is another access level And so if the user isn't signed in he's a public it will this will validate true in the query Ok so We set that up simply by adding access level In A access [00:29:28](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h29m28s) So you must check in the Main Source table For access And whether this user is in that So that means you don't need to add a state key because The code is done for you Ok That is some of the filters then the where [00:29:48](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h29m48s) Is you can add any table key Equals to a certain value now that Value could be another table like b field or it could even be a global variable like we said we could set up So it can also be in ID, a user ID now the user ID is already On the table so it could be Just user ID And or it could be like we've done it this case just an integer which is one So we wanna make sure that all the [00:30:18](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h30m18s) Sermons returned Is published And if you have an unpublished sermon it shouldn't even Return it at all Ok so That's what we doing with that That is setting up a get list query With pagination Through this Ordering method we just saying use the a ordering [00:30:39](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h30m39s) and a send now you can order all the items Just add many as you like Be sure that the table that you ordering You could even use a name right So could be a name As an ordering Table key Then it you could do it a descending or ascending Then it would be added to the query [00:31:03](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h31m03s) Ok That is also added ordering To the data set From Your Dynamic get method and so here with the joint view tables you can do very nice Dependency Calls From other tables in the backend And bring the data together into one items array [00:31:25](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h31m25s) That's basically what Dynamic get is for and as you saw We have A The normal what I call main source on the table sorry in the model And then we have this other one called get preacher So That is another Dynamic get function which we [00:31:45](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h31m45s) Looked at it's called this one Get preacher if we Open it We see it's a It's a custom Get custom And we gave it a cluster name called get preacher and this is It's relationships So it is basically having No [00:32:04](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h32m04s) Relationship there Neither here so it's It's not linking to other tables It's simply getting the preachers details Right there Simple as that But it has a filter which is basically using the same integer And access levels as the filters It's also using a where I suppose yes published and it doesn't need ordering Because it's just one preacher but I none the less added the ordering I could actually delete this [00:32:41](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h32m41s) And it doesn't have any globally settings okay so that is get preacher and so from the This settings here I don't think there's custom scripting nope from this settings here component builder writes all this code You'd see that we have this function everywhere called UI kit comp And then we using a global method a static method get ui comp it's a method that I built if you know uikit if you don't know it go to get UI kit or just google it It's a It's a JavaScript Library CSS JavaScript library which really makes modeling of your views very nice and easy And it has components that you can use So like tool tip and model [00:33:45](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h33m45s) All these kind of models but Gordian is another component And we don't load all of it's components every time so what we've done is we've Written in PHP a method that looks at Fields that are text area fields And normal text Fields no mostly okay it's Not looking at every field is only looking at the text Fields and editor Fields so in in this Component we know that this description field is a Editor field and so we are sending it to this method now you can go look at this Method Method In your helper class it's over there Here's the method so So it has the classes that already has been identified which is what this [00:34:56](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h34m56s) Initial this component area sorry Field name field value model field value is actually holding it's Holding any component names that already has been identified this gets past also here with the content then we check in the content whether there is a class UI UK underscore and if it's not false we start looping to check what What what are all the components that are in there and here is the list of the components that are available and so On-the-fly we are determining whether these components should be loaded just by Looking at the content that was placed in the description field and then we added back to this Array so it updates this eventually you have an array of All those items and in the view we go to the view [00:36:00](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h36m00s) Which in this case is gonna be preacher We open the view dot HTML We get to a place which basically everything is gonna be happening so These are of the components that go in component builder compiled the application it looks inside of the content of your site view as well as your custom admin View and it identify that these components must be loaded for uikit and so it Places it here dynamically but since you could've added some components inside of the script that that is stored in the description area it now has this get uikit component which basically reach back into the model and in the model gets this Variables value through a method which is here at the bottom of the page there it is [00:37:04](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h37m04s) Get UI kit component basically through this method it is reaching in Into getting that array and once it has that array we basically check whether it is set Whether it is an array and if it is an array we set To the array that is already on this page then over here we loop through that array And we load in those components CSS and JavaScript as required so that You always can be sure that the UI kits needed components will be loaded on the page simply by user adding some of that components to its description as style Because the way uikit works is you just like Bootstrap you just Add the class name To the specific div or tag html tag and then it activates the needed scripting around it which is a nice library but it's [00:38:08](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h38m08s) Quite heavy and you don't want it on the page every time now I know you could have done this through JavaScript You know it is fact they have a way for you to do this through the JavaScript but to me I felt Let me do the most work in the html so relieve the load on the on the server And that the browser already has much more Leverage and Freedom so that's why we This feature this is maybe Beyond the scope of the get the dynamic get But since we ran into I quickly mentioned it here okay so it is all Also placed in the query that is developed by Dynamic get that's partly why it Fits so once you've got your Dynamic get set up you now will add these dynamic Gets to either site views or to admin custom admin views so these Dynamic gets is what What gets the data for you and it's where you model the data that you want to work with and you can then [00:39:12](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h39m12s) Use them in site views and custom admin views. Now next stop we will look at adding it to a site view and how all of that works. Thank you for watching. +# DynamicGet + +**Sermon - Preacher Get Example** + +Hi we still working with sermon distributor. I'm going to use this preacher, which is a get that I already have set up here. I'll use that in our illustration. Here we can see that I have this back end [00:00:25](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h00m25s) view selected. So let me select nothing. This is usually how it will look when you start. You'd look select this, (depending on which [00:00:39](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h00m39s) area of the back end you want to get the data from) you'd select back end view. Which is the best way to do it. + +**Dynamic Get Source Selection** + +Then there is the Joomla database option. Would gives you the access to draw data from any other component installed that moment in the Joomla Website. [00:01:01](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h01m01s) If you select your Joomla database, you can select any database that is actually at that stage on your database installed. That means you can reach out to other components through this dynamic get. I'm not going to do that. [00:01:21](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h01m21s) In fact that's also an area which I haven't tested so well. You possibly might try to implement that and ran into some bugs. This stage I can't make any apologies for that since the thing you should do is, instead using back end view option. [00:01:42](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h01m42s) You might say but why is the other option there? Well it's because that's a feature we certainly want in the application. I'm busy working in that direction, busy programming so did that feature will work without any problems. In fact for the most part if you don't do very complex mapping, if you just do a simple direct database fetch like that(cb_associations), you will be able to use this, it won't give you an issue. [00:02:09](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m09s) What it really is about, is these other linked or joint database structures. That would make it complex. That might cause problems. I'm not 100% sure. Obviously it did work. I haven't tested it well enough as well as I have tested the other part and that is this back-end view. [00:02:32](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m32s) + +There is also the custom option. Where you can just dump the whole option of using component builder to write your PHP for you. Here(custom Get) you can add custom PHP, it will add the methods data for you. This is a custom get option where you write the code [00:02:55](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m55s) by hand. Where as this(Custom - dropdown) option writes the code for you. You'd select the back end view that you want to use. That back end view will be the view that you connected to your component. You need to type your name in here, and then select that package, and it will load [00:03:20](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m20s) all the field names, like a.id, and a.asset, id, and a.name, and allias, and icon. + +**Dynamic Get Preacher View** + +These are all the fields inside of this(Preacher) view. I will load it and I'll put this as asset_id. I would suggest you don't change that. What you can do is you can take out a row. [00:03:50](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m50s) You can remove a row like that, and you can say I don't need that row. I don't need these. Way to there, that's all the data you might want. And then you will know that this would be the variable name of the data on when these get is used. [00:04:13](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m13s) That is the basic part of setting up a Get. + +**Get Types - Get Item/List Get Custom** + +I need to mention that you have getTypes as well. The getTypes have 4 of them. The getitem which will get one item from this preacher table. Then you got the getlistquery which will get multiple items. [00:04:41](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m41s) Depending on how many items you want to get from the database, you would select either get item or get list. Then you get getcustom, and then you got getcustoms, that plural. The difference between these two or four is the getitem is what you will use only once per [00:05:04](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h05m04s) view. + +If you are building a custom admin view, you will select a main get either, or a getitem or a getlist. You can add multiple getcustom item or getcustoms item. You can see these as other methods that you're adding to the page, but it's not the main method. [00:05:30](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h05m30s) You have main methods which are these getitem and getlistquery. Which by the way is the exact naming of the methods that will be used. Then you have this getcustom and getcustoms, which is almost same as these two, it's just that they are not main. There will only be another method in the model which will bring data to the view. You can add as many getcustom and getcustoms [00:06:00](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m00s) methods to your view as you like, but you could only add one getitem, and one getlistquery. Usually the way we would decide on this is that we would say what is the main objective of the view? What is the main dataset that we want to use in the view? That is what we will use in the getlistquery and getitem.[00:06:27](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m27s) + +**Get List Pagination** + +If the main purpose of the view show preachers, a list of preachers, I would use the getlistquery as the main selection here. Now you see that you have when you do a listquery, you have the option of adding pagination. That would mean whether the data should only return a certain number. Joomla has a global number. Which you set in the system administrative area under your global settings. [00:07:00](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h07m00s) Go to system, then global configuration, then you see there is a default list limit. That is what will be use as the amount that limits the data being returned to the page. It will only return at this stage 20 items. [00:07:26](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h07m26s) If I set that pagination to yes. If I set it to no, it will load all the data. Yes would just load some of it, and no will load all of the data. Depends on what you want to do. If you want to do an Ajax, you want to be sure that all the data is being loaded every time. You rather use JavaScript set up pagination for your view, then that is why you would use the no switch most of the time, just say yes. [00:08:00](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m00s) Component builder will automatically add the pagination code to the page. It will also automatically add pagination code to the model, at the bottom of the page, it will show a 1, 2, 3 pagination. Depending on the template you are using and the styles that are on the page. If bootstrap is not on the page, that 1, 2, 3 might possibly not look right and you will need to add styling to it. [00:08:31](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m31s) Component Builder doesn't know what style is on your page so they cannot make provision for all of that. But it actually can load the pagination itself. it + +**Join Data Vieews - Tables** + +Now here you have data and you can join this data to other database tables. Again here like with the main source you're able to select [00:08:57](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m57s) joint views from a table. A view table which is the views of the component or just any database table. To one of the database tables I often connect to categories. Component builder integrates it's application. If you add a category field to any view, [00:09:22](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m22s) it dynamically set up a category for your component. And integrates the category concept into your component, so it writes all that code for you and the way that Joomla's own applications like article manager does it. It's using the same conventions. If you know how Joomla article manager is bringing categories into the articles, then that is the way your component is going to do it. Here(DB Table - cb_categories) you can select categories. [00:09:54](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m54s) You can say these switches, I'll deal with them when we come and look in more detail at this area. Then you can model the data there(Selection). And model I mean decide what you want to return you don't want to return everything from categories But the one I want to look at first is actually this joint view Table we'll come back to the DB option The joint view Table let you again select from any of the other views that is Part of your component [00:10:25](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m25s) And again you can select whether it should return a single row Or a List of rows Now when you say single row it means it's gonna literally join it To this other data set that you have as your main data or your main source It will just be another Item in the array And so that's why you can't use the name Name For example here [00:10:51](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m51s) It needs to have that That series underscore in front of it So that it doesn't clash with the other data set that possibly also has a value called name So again here if you selected you know let me just select Anything here Series You see that it will populate this area with all the fields that is in that View Then this as Button here [00:11:21](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m21s) Basically You can't use the same Alphabetic number twice in the whole In the whole query So So the whole get function can only use a once and then b once and then c once and then D So You need to make sure that the [00:11:40](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m40s) That these are set up that you can we'd made provision up to z z How many tables you can have Only in this area here and So Basically you would First decide whether this row Type what type of return it will be If you set it to multiple you see that these names automatically update [00:12:02](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m02s) Because now The way that the get method will Work Is it will create a new Method Which will get this data And add it into your item list Via this relationship so I'm adding the on field as the Dot a series that's where the ID is for the series [00:12:24](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m24s) And the joint field I'm using the C ID which is that one So that means in the main Database That is the a database There must be a field called series And it has the ID of the series And it corresponds to the ID in this list And if I wanted to return a multiple it means that The main database which is in that case a sermon Can be linked to multiple serieses But in the system we are working with here [00:12:56](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m56s) That is not possible you can only Connect a sermon to one series So that means it's certainly a single return Then it will immediately add this Series underscore in front of everything to insure doesn't clash with your a table That's What It's basically doing Again you can remove the fields you don't want but Please do not edit [00:13:18](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m18s) The string It possibly would make it break I wanted to be possible that you can change this name to anything you like And we are gonna try and do that eventually but for now it's still doesn't really like you doing that And it it in fact you can be changing it it will still write it this way in the code that's That's part of why I'm saying you shouldn't change it not because it will break something but because it will be ignored and you might expect something else than what it is actually doing So it still is gonna use this Implementation even if you change it [00:13:54](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m54s) But it will drop the fields you don't select so if you say I don't want these That Then it won't get those Fields and you will only have this data returned And again here you can have equal Not equal Equal or not And we also have in function That means [00:14:22](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m22s) if This joint value Sorry If this on field Is an array Then you can use the in function To make sure that it Actually looks whether the id in this That's the in function And again Remember when we started out I told you that you need to be willing to get your hands dirty [00:14:45](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m45s) Now This code If we go to the component itself I'll show you where it writes this code So Let me scroll down to the bottom here And let's see we're looking into sermon Preacher ID Now we'll still get to why it says preacher ID When we look at the filters and the where [00:15:06](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15m06s) but let us go to the code Now you can actually see I'm gonna refresh this page and then go to the code Ok so since this get is used in the front Of the component we will go to the front end and not to the admin area So we go to the front end Of sermon distributor And then we are Looking at the model right the get Dynamic get is used in the model to get the data [00:15:33](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15m33s) And we are looking at sermons let me just make sure of that Yes it's sermons Getting a list query and it's using pagination Getting all this So we're Looking at sermons Sermons on the Under the preacher ID so it should be this model I'll still show you the way that I know all that [00:16:02](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m02s) But just that I could get you into the code here You can see the main Method Which actually has this dot ID or the main Data set sorry not method data set It is written here So here you can see ID, acid ID name alias link types short description [00:16:26](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m26s) If you look at the UI it says the same things, alias, link type short description Icon preacher series category ID So this is where it writes it And it shows you where in the complier it's done that Then it sets up the Second one Series you see And Then You can also see it says series [00:16:50](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m50s) Equals c ID So series There is series Equals The c This table series ID And then it also tells you what it wants from c it wants the name and the alias and then it wants a series name that Changes it to series [00:17:12](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h17m12s) Since this is in the select Query this is one function there And So that array And Transposes to this array That is the way that you make use of Joomla's Database PPI So it has a thing called quote name [00:17:35](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h17m35s) Which you can pass to arrays And the first array being the actual Name of the Value which in this case is name and alias And the second array What you wanted to be once the query is completed So it links this into the the query One-by-one See all of those even the category one is linked in here And then [00:17:59](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h17m59s) It does a check whether there's an ID And if it exists it checks whether it's a string If it's a string it adds a quote And if it isn't if it's a number It just adds it directly and That is where Where the query is done And here basically return false if there is no ID And so we'll look at this area in a moment this is done [00:18:23](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h18m23s) To the filtering and the wear Ok So I just wanted to show how it adds this Preacher as well as series To the query if we Look at the back Open up here You see that series And preacher [00:18:41](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h18m41s) And statistics but statistics You see we select Multiple statistics Because for one sermon There can be multiple downloads right So there's multiple statistics Oh sorry not multiple downloads multiple files And per file there will be a a a number So if we look at how he does that [00:19:02](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h19m02s) It is first does the query and hearing get item It actually Adds a new function Called Get ID sermon statistics and with a With a random Key To ensure that it doesn't conflict with any other method on the page We had to add this random key here And it puts it into this variable and that something that you need to [00:19:27](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h19m27s) Come and look at And Possibly when we look at the the site Layout area as well as the tablets I'll be talking about this transition here again And the fact that you need to know That it is in this variable And I'm trying inside of your layouts and your site views and these things I'm trying to give you the correct name But it is not [00:19:51](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h19m51s) Water tight correctly Possibly you need to come and check this if it doesn't just work But again I'll explain that when we get there just that you know We're adding statistics into this variable through a method which is also on the page and we passing the ID Of of the sermon So if you look at UI This exactly what we're saying here We're saying Okay get statistics multiple [00:20:19](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h20m19s) so we Went to the left Can you can select any of these And then Use the main table dot ID Must be equal to e.sermon And then this is the only values I want to return From the e.sermon So the e.sermon is this value here okay o I'm saying a ID must equal is e.sermon [00:20:48](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h20m48s) And then if you look at the code It basically if we go to this function which should be just here there it is. It takes that ID And Places that next to e.sermon and puts into its place Basically also here's the two arrays what it What it is in the database and what it should be now And it checks whether executes, checks whether it's got any arrays or any values [00:21:17](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h21m17s) And then returns that is an object List And that then gets placed inside of this Space inside here Now you would see this area here Is actually custom scripting So if we go back to the dynamic get you see that there is a custom script area here If you click on that You'd see that there is Different switches [00:21:54](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h21m54s) You can select Get list query Or before getting the items After getting the items If you select after getting the items And you place any code there Then data gets dumped right after The initial items we've Received It will it will add that [00:22:14](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h22m14s) Code in there and then only return The items So that is why you can model the data Right there in the dynamic get You gonna write the code For the data After it's been get And you can check If I remove this Code here you'd see tells you that there is an array of items [00:22:33](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h22m33s) Where all values are And then I'm just saying I want to be sure that those items are set and that they are there Before I start doing it on each of them And so again here I'm using Some double You know the street bracket component helper functions to check whether the String is there So you can dump some nice PHP Even before getting the item you can add some filters or get list query [00:23:02](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h23m02s) Before the if you if this is model list If this is item You'd see that Then there's a different set of Switches is available And so it Adjusts to To the type of Query type up here Ok [00:23:19](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h23m19s) Coming back to this area Let's again look at the database table option Basically you see I selected category and it's a single row that's returned I called it b I joined it left and I said a Cat ID must be equal to b ID Which is the ID of the category And I only want The title And the alias So that is [00:23:44](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h23m44s) how we set that up I need a title in the alias And it returns that for us Then It links it in there and that's part of what you saw here when You looked at the query option here Basically the sixth section here Now let's look at the filters You see where we've a filter And a where and an ordering and setting of Globals [00:24:12](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h24m12s) now the setting of Globals if you have a value in this query That you possibly want to use in a custom query which isn't even Setup yet but you want you know I'm gonna need this value in the model Then you can through this Global option here You can set a global area now Again here you should maybe test it There is an option of using this and State [00:24:38](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h24m38s) there is the different type of Set types You can set the value to state or you can set the value to this And here you need to know key so So let's I wanna do the name Obviously in this case is not gonna work ideal Because you got more than one name So usually this Global function only functions well [00:25:01](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h25m01s) When you are returning a single Item so when you only do get item not get list query But you do get Item Then this make sense and then you can give it a name And it will add it to the global Scope of the method or the model rather Which you can access through other [00:25:24](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h25m24s) Model Methods Which are custom Methods Ok so that is setting the global The filtering You have a a list of possible filtering So Depending on what you wanna do You might select ID or user or access level or group or category [00:25:45](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h25m45s) or Tags or date Some of these are not really well formulated yet like date doesn't work that well yet But categories does user group access level user and ID does well You know this function variable works well and Array Array value repeatable value and other All those already work very well And you can already use them and Implement them Now the only way for you to really [00:26:15](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h26m15s) Know exactly how it works you need to know a little PHP and then you need to compile and go look in the code what it has done and where it's placed what And that Is Why I showed you that this is all set in the model Ok So currently We are saying we wanted to do a J request Get into here by ID [00:26:39](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h26m39s) So this is the get area that I added I look in The code it says State the key and it's this Here you see and we set it is a function variable So it doesn't change or adapt this at all And then says it must be equal to preacher So what we are doing since component builder doesn't know where the this variable is gonna be a string or integer That's why we have this function which first checks were that is string [00:27:08](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h27m08s) And then checks whether it's a number And related and builds up the query respectively You might feel that is too much and you're Possibly right But that is the only way I am implement it at this stage And getting more developers involved May possibly improve this long run Then you see there the Access Now we have a bunch of values that fire every time in a custom [00:27:39](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h27m39s) Dynamic get model And it is the these values And often times you you might need these values So instead of you Having to do custom scripting to get these values on the page We add these values dynamically every time So the user ID the group The authorised group the access level The app and then the input values Which by other URL or post is on the page [00:28:08](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h28m08s) And it tells you that it's been initiated so This is set to true so that if you have custom Methods Like this one get Preacher It's checks whether it's been set And if it has been set it doesn't set that again it can just use it But if it hasn't been set it sets it and also again sets it to true So [00:28:32](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h28m32s) variables Global variables Can then be used inside of the coaches like the global variable we spoke of earlier Ok so Out of that Global variable We are Actually accessing This levels And so it's this one here Which basically has the get authorized view levels Of the specific user [00:29:00](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h29m00s) That is now you know accessed this Model or the view that this model belongs to And if he is in these access levels So you remember that public is another access level And so if the user isn't signed in he's a public it will this will validate true in the query Ok so We set that up simply by adding access level In A access [00:29:28](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h29m28s) So you must check in the Main Source table For access And whether this user is in that So that means you don't need to add a state key because The code is done for you Ok That is some of the filters then the where [00:29:48](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h29m48s) Is you can add any table key Equals to a certain value now that Value could be another table like b field or it could even be a global variable like we said we could set up So it can also be in ID, a user ID now the user ID is already On the table so it could be Just user ID And or it could be like we've done it this case just an integer which is one So we wanna make sure that all the [00:30:18](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h30m18s) Sermons returned Is published And if you have an unpublished sermon it shouldn't even Return it at all Ok so That's what we doing with that That is setting up a get list query With pagination Through this Ordering method we just saying use the a ordering [00:30:39](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h30m39s) and a send now you can order all the items Just add many as you like Be sure that the table that you ordering You could even use a name right So could be a name As an ordering Table key Then it you could do it a descending or ascending Then it would be added to the query [00:31:03](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h31m03s) Ok That is also added ordering To the data set From Your Dynamic get method and so here with the joint view tables you can do very nice Dependency Calls From other tables in the backend And bring the data together into one items array [00:31:25](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h31m25s) That's basically what Dynamic get is for and as you saw We have A The normal what I call main source on the table sorry in the model And then we have this other one called get preacher So That is another Dynamic get function which we [00:31:45](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h31m45s) Looked at it's called this one Get preacher if we Open it We see it's a It's a custom Get custom And we gave it a cluster name called get preacher and this is It's relationships So it is basically having No [00:32:04](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h32m04s) Relationship there Neither here so it's It's not linking to other tables It's simply getting the preachers details Right there Simple as that But it has a filter which is basically using the same integer And access levels as the filters It's also using a where I suppose yes published and it doesn't need ordering Because it's just one preacher but I none the less added the ordering I could actually delete this [00:32:41](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h32m41s) And it doesn't have any globally settings okay so that is get preacher and so from the This settings here I don't think there's custom scripting nope from this settings here component builder writes all this code You'd see that we have this function everywhere called UI kit comp And then we using a global method a static method get ui comp it's a method that I built if you know uikit if you don't know it go to get UI kit or just google it It's a It's a JavaScript Library CSS JavaScript library which really makes modeling of your views very nice and easy And it has components that you can use So like tool tip and model [00:33:45](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h33m45s) All these kind of models but Gordian is another component And we don't load all of it's components every time so what we've done is we've Written in PHP a method that looks at Fields that are text area fields And normal text Fields no mostly okay it's Not looking at every field is only looking at the text Fields and editor Fields so in in this Component we know that this description field is a Editor field and so we are sending it to this method now you can go look at this Method Method In your helper class it's over there Here's the method so So it has the classes that already has been identified which is what this [00:34:56](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h34m56s) Initial this component area sorry Field name field value model field value is actually holding it's Holding any component names that already has been identified this gets past also here with the content then we check in the content whether there is a class UI UK underscore and if it's not false we start looping to check what What what are all the components that are in there and here is the list of the components that are available and so On-the-fly we are determining whether these components should be loaded just by Looking at the content that was placed in the description field and then we added back to this Array so it updates this eventually you have an array of All those items and in the view we go to the view [00:36:00](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h36m00s) Which in this case is gonna be preacher We open the view dot HTML We get to a place which basically everything is gonna be happening so These are of the components that go in component builder compiled the application it looks inside of the content of your site view as well as your custom admin View and it identify that these components must be loaded for uikit and so it Places it here dynamically but since you could've added some components inside of the script that that is stored in the description area it now has this get uikit component which basically reach back into the model and in the model gets this Variables value through a method which is here at the bottom of the page there it is [00:37:04](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h37m04s) Get UI kit component basically through this method it is reaching in Into getting that array and once it has that array we basically check whether it is set Whether it is an array and if it is an array we set To the array that is already on this page then over here we loop through that array And we load in those components CSS and JavaScript as required so that You always can be sure that the UI kits needed components will be loaded on the page simply by user adding some of that components to its description as style Because the way uikit works is you just like Bootstrap you just Add the class name To the specific div or tag html tag and then it activates the needed scripting around it which is a nice library but it's [00:38:08](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h38m08s) Quite heavy and you don't want it on the page every time now I know you could have done this through JavaScript You know it is fact they have a way for you to do this through the JavaScript but to me I felt Let me do the most work in the html so relieve the load on the on the server And that the browser already has much more Leverage and Freedom so that's why we This feature this is maybe Beyond the scope of the get the dynamic get But since we ran into I quickly mentioned it here okay so it is all Also placed in the query that is developed by Dynamic get that's partly why it Fits so once you've got your Dynamic get set up you now will add these dynamic Gets to either site views or to admin custom admin views so these Dynamic gets is what What gets the data for you and it's where you model the data that you want to work with and you can then [00:39:12](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h39m12s) Use them in site views and custom admin views. Now next stop we will look at adding it to a site view and how all of that works. Thank you for watching.