Updated 013 dynamicGet (markdown)
parent
865135c2bd
commit
9eab029dab
@ -45,22 +45,21 @@ The unwanted fields can be removed but the string should not be editted as it ma
|
||||
|
||||
Where is the code is written? If we are looking into sermon 'preacher id'. We'll 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) Let's go to the code. First refresh this page, and then go to the code. Since this 'get' is used in the front of the component, we will go to the front end and not to the admin area. Go to the front end of 'sermon distributor'. The 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) It's getting a list query and it's using pagination getting all this. [00:16:02](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m02s) Going into the code, the main method which has this id(a.name)or the data set may be seen. It is written here(selected area on video). Here you can see 'id', 'asset', 'name', 'alias', 'link', 'types' and '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' and 'id'. This is where it writes it. It shows you where in the compiler it has been done. Then it sets up the second one; 'series'. [00:16:50](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m50s) It says; 'series = c.id''. So series, there(see video) is 'series', '=', the 'c', 'this table', 'series' and 'id'. 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. That array 'array'(c.name)','c.alias' transposes to this array 'array'(series_name','series_alias'). That is how to use Joomla's database API. It has a thing called 'quotename', which you can pass to arrays.<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<,
|
||||
If you look at the UI it says the same things, 'alias', 'link', 'type', 'short description', 'icon', 'preacher', 'series', 'category' and 'id'. This is where it writes it. It shows you where in the compiler it has been done. Then it sets up the second one; 'series'. [00:16:50](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m50s) It says; 'series = c.id''. So series, there(see video) is 'series', '=', the 'c', 'this table', 'series' and 'id'. 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. That array 'array'(c.name)','c.alias' transposes to this array 'array'(series_name','series_alias'). That is how to use Joomla's database API. It has a thing called 'quotename', which you can pass to arrays.[00:17:35](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h17m35s)The first array being the name of the value, which in this case is 'name' and 'alias'. The second array, is what is needed once the query is completed. So it links this(selected area on video) into the the query one-by-one. All of those even the category one is linked in here. 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. If it exists, it checks whether it's a string. If it's a string, it adds a quote. If it isn't, if it is a number, it adds it directly. That is where the query is done, here return false if there is no id. We'll look at this area in a moment. [00:18:23](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h18m23s) This is done through the 'filtering' and the 'where'.
|
||||
|
||||
A example of how it adds this preacher as well as series to the query:
|
||||
If you look at the back, open up 'Join View Tables - Add', you will see that series and preacher [00:18:41](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h18m41s) and statistics. Multiple statistics are selected because for one sermon there can be multiple files, and there will be a number per file. [00:19:02](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h19m02s) It is first does the query and here in 'getitem', it adds a new function called 'getidSermonstatistics' and with a random key 'Fcff_E' to ensure that it doesn't conflict with any other method on the page. We had to add this 'Fcff_E' random key. It puts it into this variable. 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.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[00:17:35](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h17m35s)The first array being the name of the value, which in this case is name and alias. The second array, is what you want once the query is completed. So it links this(selected area on video) into the the query one-by-one. All of those even the category one is linked in here. 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. If it exists, it checks whether it's a string. If it's a string, it adds a quote. If it isn't a number, it adds it directly. That is where the query is done, here return false if there is no id. 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 where.
|
||||
|
||||
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(Join View Tables - Add), you see that series and preacher [00:18:41](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h18m41s) and statistics. We select multiple statistics because for one sermon there can be multiple files, and per file there will be 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 here in getitem, it adds a new function called 'getidSermonstatistics' and with a random key(Fcff_E) to ensure that it doesn't conflict with any other method on the page. We had to add this(Fcff_E) random key here. It puts it into this variable. 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.
|
||||
|
||||
Possibly when we look at the site layout area as well as the templates, I'll be talking about this transition here again. What you need to know is that this variable, And I'm trying, inside of your layouts and your site views and these things, 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) type correctly. Possibly you need to come and check this if it doesn't work. I'll explain that when we get there. We're adding statistics into this(idsermonstatistic) variable through a method which is also on the page and we passing the id of the sermon. If you look at UI, this is exactly what we're saying here. We're saying, get statistics multiple, [00:20:19](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h20m19s) join to the left. You can select any of these(dropdown). Then use the main table dot a.id, it must be equal to e.sermon. Then this is the only values I want to return from the e.sermon. The e.sermon is this(see video) value here. I'm saying a.id must equal with e.sermon. [00:20:48](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h20m48s) If you look at the code, if we go to this function(idsermonstatisticFcff_E), it takes the id and places it next to e.sermon. Puts into its place. Here's the two arrays. What it is in the database, and what it should be now. It checks whether it executes or 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) Then returns that as an object list, that then gets placed inside of this space inside here.
|
||||
Possibly when we look at the site layout area as well as the templates, 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, 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) watertight correct. Possibly you need to come and check this if it doesn't work. I'll explain that when we get there. We're adding statistics into this(idsermonstatistic) variable through a method which is also on the page and we passing the ID of the sermon. If you look at UI for instance, and go to 'statistics', 'multiple' and [00:20:19](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h20m19s) join to the left. You can select any of these(dropdown'. Then use the main table 'a.id', it must be equal to 'e.sermon'. Then this is the only values that needs to return from the 'e.sermon'. The 'e.sermon' is this(see video) value here, and 'a.id' must equal with e.sermon. [00:20:48](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h20m48s) If you look at the code, if we go to this function(idsermonstatisticFcff_E), it takes the 'id' and places it next to 'e.sermon'. Here's the two arrays. What it is in the database, and what it should be now. It checks whether it got any arrays or any values. [00:21:17](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h21m17s) Then returns that as an object list, that then gets placed in this space.(See video)
|
||||
|
||||
### Dynamic Get Custom Script
|
||||
|
||||
Now you would see this area here(see video) is custom scripting. If we go back to the dynamic get, you will see that there is a custom script area. If you click on it, 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 'getlistquery' or 'before getting the items'and '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 add that [00:22:14](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h22m14s) code in there, and then return the items. That is why you can model the data right there in the dynamic get. You going to write the code for the data after it's been get. You can check if I remove this code here, you'd see it tells you that there is an array of items [00:22:33](https://wmalfuntionww.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h22m33s) where all values are. 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. Here I'm using the string bracket component helper functions to check whether the string is there. 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) if this is model list. If this is item, you'd see that there's a different set of switches is available. It adjusts to the type of query up here. [00:23:19](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h23m19s)
|
||||
Returning to the dynamic get, it can be seen that there is a custom script area. If you click on it, you will see different switches. [00:21:54](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h21m54s) You can select 'getlistquery' or 'before getting the items' and '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 you have received. (https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h22m14s) It will add that [00:22:14] code in there, and then return the items. That is why you can model the data right there in the dynamic get. You are going to write the code for the data after it has been 'get'. It can be checked if this code has been removed here, it will indicates if there is an array of items where all values are.[00:22:33](https://wmalfuntionww.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h22m33s) <<<<<<<
|
||||
|
||||
|
||||
|
||||
|
||||
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. Here I'm using the string bracket component helper functions to check whether the string is there. 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) if this is model list. If this is item, you'd see that there's a different set of switches is available. It adjusts to the type of query up here. [00:23:19](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h23m19s)
|
||||
|
||||
### Dynamic Get Join DB Tables
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user