Updated 013 dynamicGet (markdown)

Amigo 2019-06-18 08:26:43 +02:00
parent 901915a9d7
commit 7cb16221eb
1 changed files with 13 additions and 12 deletions

@ -63,27 +63,28 @@ Coming back to this 'Join View Tables' area. Let's again look at the database ta
Taking a look at the filters. Here is a 'filter',a'where', an 'ordering' and a 'setting' of globals. [00:24:12](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h24m12s) The 'setting' of globals is 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 to know if this value is needed in the model. Then through this global option here, a global area can be set. Maybe it should be tested here(See video) . There is an option of using 'This' and 'State'. [00:24:38](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h24m38s) It is the different set types. You can set the value to 'State' or you can set the value to 'This'.
It is nessesary to know the key. If for example 'name' is used: In this case it is not going to work because there is more than one name. Usually this global function only functions well when you are returning a single item.[00:25:01](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h25m01s) When 'getitem' not 'getlistquery' is done, it makes sense and then you can give it a name. It will add it to the global scope of the model which you can access through other model methods which are custom methods. That is setting the global. [00:25:24](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h25m24s) There is a list of possible filtering. Depending on what needs to be done, 'ID','user', 'access, 'level', 'group', 'category', 'tags' or 'date' may be selected.[00:25:45](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h25m45s) Some of these are not formulated yet. Like 'date' doesn't work that well yet. 'Categories' does, 'user', 'group', 'access level', 'user' and 'id' does well. The function 'variable' works well. As well as 'array', 'value', 'repeatable value'', and other work very well. You can use them and implement them. [00:26:15](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h26m15s) The only way to know exactly how it works is to know a little PHP, and then you need to compile it and go look in the code what it has done and where it's placed what. That is why all this is set in the model. Currently we are saying we wanted to do a 'JRequest::getint by id'. [00:26:39](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h26m39s)This is the get area that has been added. If you look in the code you will see 'State Key' and this, 'JRequest::getint by id'. It is a function variable, it does not change or adapt this at all. Then it indicates that it must be equal to 'preacher'. Since Component Builder doesn't know if this variable is going to be a string or integer, therefore this function first needs to check if it is a string, and then checks whether it's a number and builds up the query respectively. It is the only way to implement it at this stage. [00:27:08](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h27m08s)<<<<<<<<<<<<<<<<<<<<<<<
It is nessesary to know the key. If for example 'name' is used: In this case it is not going to work because there is more than one name. Usually this global function only functions well when you are returning a single item.[00:25:01](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h25m01s) When 'getitem' not 'getlistquery' is done, it makes sense and then you can give it a name. It will add it to the global scope of the model which you can access through other model methods which are custom methods. That is setting the global. [00:25:24](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h25m24s) There is a list of possible filtering. Depending on what needs to be done, 'ID','user', 'access, 'level', 'group', 'category', 'tags' or 'date' may be selected.[00:25:45](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h25m45s) Some of these are not formulated yet. Like 'date' doesn't work that well yet. 'Categories' does, 'user', 'group', 'access level', 'user' and 'id' does well. The function 'variable' works well. As well as 'array', 'value', 'repeatable value'', and other work very well. You can use them and implement them. [00:26:15](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h26m15s) The only way to know exactly how it works is to know a little PHP, and then you need to compile it and go look in the code what it has done and where it's placed what. That is why all this is set in the model. Currently we are saying we wanted to do a 'JRequest::getint by id'. [00:26:39](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h26m39s)This is the get area that has been added. If you look in the code you will see 'State Key' and this, 'JRequest::getint by id'. It is a function variable, it does not change or adapt this at all. Then it indicates that it must be equal to 'preacher'. Since Component Builder doesn't know if this variable is going to be a string or integer, therefore this function first needs to check if it is a string, and then checks whether it's a number and builds up the query respectively. It is the only way to implement it at this stage. [00:27:08](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h27m08s)
### Dynamic Get Get Access( Default added)
Then there is the 'Access'. We have a bunch of values that fire every time in a custom dynamic get model.[00:27:39](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h27m39s) It is the these(see video) values that you often might need. Instead of you having to do custom scripting to get these values on the page, these values dynamically gets added every time. The 'userid', the 'group', the 'authorised group', the 'access level', the 'app', and then the 'input values', which is by either URL or post is on the page, [00:28:08](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h28m08s) and indicates that it has been initiated, and set it to true. That is if you have custom methods, like this one 'getpreacher', it checks whether it has been set. If it has been set it does not set that again, it is ready to be used. But if it has not been set, it sets it, and also again sets it to true. [00:28:32](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h28m32s) These global variables can be used inside of the code like the global variable we spoke of earlier. Out of that global variable we are accessing this 'levels', which 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 has now accessed this model or the view that this model belongs to. If he is in these access levels. You remember that 'public' is another access level. If the user isn't signed in, he is 'public'. This will validate true in the query. 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) You must check in the main source table for 'a.access' whether the user is in that. That means you don't need to add a 'state key' because the code is done for you. That is some of the filters.
Then you see the access. 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. It is the these(see video) values. Often times you might need these values. Instead of you having to do custom scripting to get these values on the page, we add these values dynamically every time. The userid, 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, and set it to true. That is if you have custom methods, like this one getpreacher, it checks whether it's been set. 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. [00:28:32](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h28m32s) These global variables can be used inside of the code like the global variable we spoke of earlier. Out of that global variable we are accessing this 'levels', which 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 accessed this model or the view that this model belongs to. If he is in these access levels. You remember that public is another access level. If the user isn't signed in, he's a public. This will validate true in the query. 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) You must check in the main source table for a.access whether the user is in that. That means you don't need to add a state key because the code is done for you. That is some of the filters.
### Dynamic Get "Where"
### Dynamic Get Where
Then the where. [00:29:48](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h29m48s) You can add any table key equals to a certain value. That value could be another table like b.field or it could even be a global variable like we said we could set up. It can also be an id, a userid. The userid is already on the table. It could be like we've done it in this case just an integer which is one. We want to make sure that all the [00:30:18](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h30m18s) sermons returned is published. If you have an unpublished sermon it shouldn't even return it at all.
[00:29:48](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h29m48s) You can add any table key equals to a certain value. That value could be another table like "b.field" or it could even be a global variable like we said we could set up. It can also be an 'id', a 'userid'. The 'userid' is already on the table. It could be like we have done in this case, only an integer which is '1'. It is important to make sure that all the [00:30:18](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h30m18s) sermons returned is published. If you have an unpublished sermon it will not be returned at all.
### Dynamic Get Ordering
That is setting up a getlistquery 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 send. You can order all the items. Just add many as you like. Be sure that the table that you ordering, could even use a name. It could be a name as an ordering table key. Then you could do a descending or ascending. It would be added to the query. [00:31:03](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h31m03s) That is also added ordering to the data set from your dynamic get method. Here with the joint view tables you can do very nice dependency calls from other tables in the back end, 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 what dynamic get is for. As you saw we have a main source on the model.
That is setting up a 'getlistquery' with pagination through this ordering method we just says, use the 'a.ordering' [00:30:39](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h30m39s) and send. You can order all the items. Just add many as you like. Be sure that the table that you ordering, could even use a name. It could be a 'name' as an ordering table key. Then you could do a descending or ascending. It would be added to the query. [00:31:03](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h31m03s) That is also added ordering to the data set from your dynamic get method. Here with the joint view tables you can do very nice dependency calls from other tables in the back end, 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 what dynamic get is for. As it can be seen there is a main source on the model.
Then we have this other one called getpreacher. That is another dynamic get function which we have [00:31:45](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h31m45s) looked at. It's called this one getpreacher. If we open it, we see it's a getcustom. We gave it a custom name called getpreacher. This is its relationships, So it basically having no [00:32:04](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h32m04s) relationship there. Neither here. It's not linking to other tables. It's simply getting the preachers details right there(see video) 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. [00:32:41](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h32m41s) It doesn't have any globally settings. That is getpreacher. From the this settings here, component builder writes all this code. You'd see that we have this function everywhere called UIkitComp.
Then we have this other one called 'getpreacher'. [00:31:45](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h31m45s)That is another dynamic get function which we have looked at. It's called 'getpreacher'. If it is opened, it is a 'getcustom'. We gave it a custom name called 'getpreacher'.<<<<<<<<<<<<<<<<<
This is its relationships, So it basically having no [00:32:04](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h32m04s) relationship there. Neither here. It's not linking to other tables. It's simply getting the preachers details right there(see video) 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. [00:32:41](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h32m41s) It doesn't have any globally settings. That is getpreacher. From the this settings here, component builder writes all this code. You'd see that we have this function everywhere called UIkitComp.
Then we using a global static method, getuikitcomp. It's a method that I built if you know Uikit, if you don't know it, go to getUIkit or just google.com it. It's a JavaScript, HTML Library, CSS JavaScript library, which really makes modeling of your views very nice and easy. It has components that you can use, 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. Gordian is another component. We don't load all of it's components every time. What we've done is we've written in PHP, a method that looks at fields that are text area fields. It's not looking at every field, is only looking at the text fields and editor fields. In this component we know that this description field, is a editor field, and so we are sending it to this(getuikitComp) method.