Updated 013 dynamicGet (markdown)

Amigo 2019-06-18 11:57:48 +02:00
parent 7f5fbebfa7
commit 5c559f870f
1 changed files with 8 additions and 14 deletions

@ -49,7 +49,7 @@ If you look at the UI it says the same things. It writes it here, showing you wh
An example on how it adds the preacher as well as series to the query: In the back open 'Join View Tables - Add', to find series, preacher, and statistics. [00:18:41](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h18m41s) Multiple statistics are selected because there can be multiple files for one sermon. (There will be a number per file.) [00:19:02](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h19m02s) It does the query and in 'getitem' adds a new function called 'getidSermonstatistics' with a random key, 'Fcff_E', to ensure it doesn't conflict with any other method on the page. The 'Fcff_E' random key places it into this variable. [00:19:27](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h19m27s)
When we look at the site layout area and the templates I'll talk about this transition again and the fact that you need to know that it is in this variable. I'm trying, inside of your layouts and your site views, etc, to give you the correct name, but it isn't watertight. [00:19:51](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h19m51s) You might need to check this if it doesn't work. We're adding statistics into this (idsermonstatistic) variable through a method also on the page and we are passing the ID of the sermon. [00:20:19](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h20m19s) Go to UI, 'statistics', 'multiple' and join to the left. You can select any of these. (See video.) Use the main table 'a.id'; it must be equal to 'e.sermon'. These are the only values that needs to return from the 'e.sermon'. The 'e.sermon' is this value here, and 'a.id' must equal with e.sermon. (See video.) [00:20:48](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h20m48s) In the code this function (idsermonstatisticFcff_E) takes the 'id' and places it next to 'e.sermon'. The two arrays are what it is in the database and what it should be now. It checks whether it has any arrays or any values, then returns it as an object list which gets placed in this space. (See video.) [00:21:17](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h21m17s)
When we look at the site layout area and the templates I'll talk about this transition again and the fact that you need to know that it is in this variable. I'm trying, inside of your layouts and your site views, etc, to give you the correct name, but it isn't watertight. [00:19:51](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h19m51s) You might need to check this if it doesn't work. We're adding statistics into this (idsermonstatistic) variable through a method also on the page and we are passing the ID of the sermon. [00:20:19](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h20m19s) Go to UI, 'statistics', 'multiple' and join to the left. You can select any of these. (See video.) Use the main table 'a.id'; it must be equal to 'e.sermon'. These are the only values that needs to return from the 'e.sermon'. The 'e.sermon' is this value here, and 'a.id' must equal with e.sermon. (See video.) [00:20:48](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h20m48s) In the code this function 'idsermonstatisticFcff_E' takes the 'id' and places it next to 'e.sermon'. The two arrays are what it is in the database and what it should be now. It checks whether it has any arrays or any values, then returns it as an object list which gets placed in this space. (See video.) [00:21:17](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h21m17s)
### Dynamic Get Custom Script
@ -57,7 +57,7 @@ Returning to the dynamic get, it can be seen that there is a custom script area.
### Dynamic Get Join DB Tables
Coming back to this 'Join View Tables' area. Let's again look at the database table option. If category is selected and it's a single row that is returned. It is called 'b'. It is joined to the left, and set 'a.catid' that it should be equal to 'b.id', which is the 'id' of the category. Only a title and the alias is needed. That is [00:23:44](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h23m44s) how it is set up. Only the title and the alias is nessesary and it is been returned. Then it links it in there(see video), and that's part of what is seen here when viewing the query option, it is the sixth section.
Coming back to this 'Join View Tables' area. Let's again look at the database table option. If category is selected and it's a single row that is returned. It is called 'b'. It is joined to the left, and set 'a.catid' that it should be equal to 'b.id', which is the 'id' of the category. Only a title and the alias is needed. That is how it is set up. [00:23:44](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h23m44s) Only the title and the alias is nessesary and it is been returned. Then it links it in there(see video), and that's part of what is seen here when viewing the query option, it is the sixth section.
### Dynamic Get Filters - Where - Ordering - Globals
@ -68,24 +68,18 @@ It is nessesary to know the key. If for example 'name' is used: In this case it
### 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 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, and indicates that it has been initiated, and set it to true. [00:28:08](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h28m08s) 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 that has now accessed this model or the view that this model belongs to. [00:29:00](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h29m00s) 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.
### Dynamic Get "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 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.
[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 sermons returned is published. [00:30:18](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h30m18s) 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 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.
That is setting up a 'getlistquery' with pagination through this ordering method we just says, use the 'a.ordering' and send. [00:30:39](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h30m39s) 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'. [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, in this instance it does not have any relationships. It does not link to other tables (See video) [00:32:04](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h32m04s) It simply gets the preachers details right there.(see video) But it has a filter which is basically using the same integer and access levels as the filters. It is using a 'where' and it can be seen that it is published, and that it does not need ordering, because it is one preacher. [00:32:41](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h32m41s) It doesn't have any global settings. That is 'getpreacher'. From this settings, Component Builder writes all this code. You'd see that we have this function everywhere called 'UIkitComp' and are we using a global static method, 'getuikitcomp'. It's a method that VDM has build. To get more acquinted with Uikit, go to 'getUIkit' or google it. It's a CSS JavaScript library, which really makes modeling of your views very easy. It has components that you can use, like tool tip and [00:33:45](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h33m45s) all these kind of models. Guardian is another component. Not all of it's components is loaded every time. We wrote it in PHP, a method that looks at text fields and editor fields. In this component this description field, is a editor field, and so we are sending it to this 'getuikitComp' method.
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, in this instance it does not have any relationships. It does not link to other tables (See video) [00:32:04](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h32m04s) It simply gets the preachers details right there.(see video) But it has a filter which is basically using the same integer and access levels as the filters. It is using a 'where' and it can be seen that it is published, and that it does not need ordering, because it is one preacher. [00:32:41](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h32m41s) It doesn't have any global settings. That is 'getpreacher'. From this settings, Component Builder writes all this code. You'd see that we have this function everywhere called 'UIkitComp' and are we using a global static method, 'getuikitcomp'. It's a method that VDM has build. To get more acquinted with Uikit, go to 'getUIkit' or google it. It's a CSS JavaScript library, which really makes modeling of your views very easy. It has components that you can use, like tool tip andall these kind of models. [00:33:45](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h33m45s) Guardian is another component. Not all of it's components is loaded every time. We wrote it in PHP, a method that looks at text fields and editor fields. In this component this description field, is a editor field, and so we are sending it to this 'getuikitComp' method. View this method in helper class 'sermondistributor'. It has the classes that already has been identified which is what this initial model field value is holding.[00:34:56](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h34m56s) It is holding any component names that already has been identified. This gets passed also here(classes) with the content. Then we check in the content whether there is a class='uk-' and if it's not 'false', we start looping to check what are all the components that are in there. A list of the components that are available can be seen. On-the-fly it is determined whether these components should be loaded just by looking at the content that was placed in the description field and then it is added back to this array(see video). It updates this, eventually you have an array of all those items. [00:36:00](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h36m00s) In the view, go to the 'view' which in this case is going to be 'Preacher' and open 'view.html.php'. These are of the components that when 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. It is placed here dynamically but since you could have added some components inside of the script that is stored in the description area, it now has this 'getuikitcomponent' which reaches back into the model. and in the model gets this variables' value through a method which is at the bottom of this page.[00:37:04](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h37m04s) There it is 'getuikitComp'. Through this method it is reaching in to get that array. Once it has that array we check if it is set, whether it is an array and if it is an array we set it to the array that is already on this page. Then over here(See video) you loop through that array and load in those components, CSS and JavaScript as required.
You can go look at this method in your helper class 'sermondistributor'. 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 model field value is actually holding. It is holding any component names that already has been identified. This gets passed also here(classes) with the content. Then we check in the content whether there is a class='uk-' and if it's not 'false', we start looping to check what are all the components that are in there. A list of the components that are available can be seen. On-the-fly it is determined whether these components should be loaded just by looking at the content that was placed in the description field and then it is added back to this array(see video). It updates this, eventually you have an array of all those items. [00:36:00](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h36m00s) In the view, go to the 'view' which in this case is going to be 'Preacher' and open 'view.html.php'. These are of the components that when 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.<<<<<<<
You can be sure that the Uikit's needed components will be loaded on the page, simply by 'user' adding some of that components to its description as style and while Uikit works like Bootstrap, the class name can be added to the specific DIF or HTML tag and then activates the needed scripting around it. [00:38:08](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h38m08s) That is a nice library but it is quite huge.
It places it here dynamically but since you could've added some components inside of the script that is stored in the description area, it now has this getuikitcomponent which reach back into the model. 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) getuikitComp. Through this method it is reaching in getting that array. Once it has that array we check whether it is set. Whether it is an array and if it is an array we set it to the array that is already on this page. Then over here we loop through that array we load in those components, CSS and JavaScript as required.
You can be sure that the uikits 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 html tag. 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. I know you could have done this through JavaScript. They have a way for you to do this through the JavaScript, but I do the most of the work in the html, to leave the load on the server, and that the browser already has much more leverage and freedom. That's why we added this feature. This is maybe beyond the scope of the dynamic get. It is all also placed in the query that is developed by dynamic get, that's partly why it fits. Once you've got your dynamic get set up, you will add these dynamic gets to either site views or to custom admin views. These dynamic gets is what gets the data for you. It's where you model the data that you want to work with. 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. Next stop we will look at adding it to a site view and how all of that works.
There is a way to do this through JavaScript, but I do most of it in the HTML, to leave the load on the server. That's why this feature has been added, although this is maybe beyond the scope of the dynamic get. It is all also placed in the query that is developed by dynamic get, that's partly why it fits. Once you've got your dynamic get set up, these dynamic gets may be added to either site views or to custom admin views. These 'dynamic gets' is what gets the data for you. It's where you model the data that you want to work with. 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.