Updated 013 dynamicGet (markdown)
parent
45022516cd
commit
865135c2bd
@ -38,24 +38,21 @@ The same alphabetic number may not be used twice in the whole query. The whole g
|
||||
|
||||
Decide what type of return this 'Return Row Type' have to be. If it is set to multiple, these names will automatically update. [00:12:02](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m02s) The get method will create a new method getting this data and adding it into your item list via this relationship. I'm adding the 'On Field' as the '.a' series; that is where the 'id' is for the series. [00:12:24](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m24s) In the joint field, 'c.id' is used. In the main database, that is the 'a' database. There must be a field called series. It has the id of the series. It corresponds to the id in this list. If it is necessary to return a multiple, the main database, in this case 'Sermon', can be linked to multiple series's. [00:12:56](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m56s)
|
||||
|
||||
In this system a sermon can only be connected to one series; it is certainly a single return. It will then immediately add this series_ in front of everything to insure it doesn't clash with your 'a' table. [00:13:18](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m18s)
|
||||
The unwanted fields can be removed but the string should not be editted as some further development needs to be done in this area.<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
I want it to be possible for you to change this name to anything you like. We are going to try and do that eventually. You can be changing it will still write it this way in the code. 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. Still it is going to use this implementation, even if you change it. [00:13:54](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m54s) It will drop the fields you don't select. If you say I don't want these, then it won't get those fields and you will only have this data returned. Again here you can have equal, not equal, equal or not. We also have 'IN' function. That means [00:14:22](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m22s) if this 'On field' is an array, then you can use the 'IN' function to make sure that it actually looks whether the id is in this array. That's the in function. [00:14:45](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m45s)
|
||||
In this system a sermon can only be connected to one series; it is certainly a single return. It will then immediately add this 'series_' in front of everything to insure it doesn't clash with your 'a' table. [00:13:18](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m18s)
|
||||
The unwanted fields can be removed but the string should not be editted as it may possibly malfunction .Some further development still needs to be done in this area. We want it to be possible for you to change this name to anything you like. We are going to try and do that eventually. You can be changing it but it will still write it this way in the code. [00:13:54](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m54s) It will drop the fields you don't select. If you say that you don't want these, then it won't get those fields and you will only have this data returned. Again here you can have equal, not equal, equal or not. We also have 'IN' function. [00:14:22](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m22s)That means if this 'On field' is an array, then you can use the 'IN' function to make sure that it actually looks whether the ID is in this array. That's the 'IN' function. [00:14:45](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m45s)
|
||||
|
||||
### Dynamic Get Preacher In Code
|
||||
|
||||
This code if we go to the component itself, I'll show you where it writes this code. We're 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. You can actually see I'm going to 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. We go to the front end of sermon distributor. Then we are looking at the model. 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) We are looking at sermons. Let me just make sure if that. Yes, it's sermons. It's getting a list query and it's using pagination getting all this. We're looking at sermons. Sermons under the preacher id, it should be this model. [00:16:02](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m02s) I could get you into the code. You can see the main method which has this id(a.name)or the data set. It is written here(selected area on video). Here you can see id, asset, name, alias, link, types, short description. [00:16:26](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m26s)
|
||||
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, id. This is where it writes it. It shows you where in the compiler it's done. Then it sets up the second one series. You can also see it says series [00:16:50](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m50s) = c.id. So series, there(see video) is series, =, the c, this table, series, 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 the way that you make use of Joomla's database API. It has a thing called quotename [00:17:35](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h17m35s) which you can pass to arrays. 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 wear.
|
||||
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 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.
|
||||
|
||||
@ -63,7 +60,7 @@ Possibly when we look at the site layout area as well as the templates, I'll be
|
||||
|
||||
### 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://www.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)
|
||||
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)
|
||||
|
||||
### Dynamic Get Join DB Tables
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user