diff --git a/013-dynamicGet.md b/013-dynamicGet.md index 2ccfc1e..7854be4 100644 --- a/013-dynamicGet.md +++ b/013-dynamicGet.md @@ -58,8 +58,21 @@ Coming back to this(Join View Tables) area. Let's again look at the database tab Now let's look at the filters where we have a filter and an ordering and 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 want to use in a custom query, which isn't even setup yet, but you want you know I'm going to need this value in the model. Then you can through this global option here, you can set a global area. 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 of set types. You can set the value to 'State' or you can set the value to 'This'. Here you need to know the key. I want to do the name, in this case is not going to work. Because you got more than one name. 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. When you do getitem not getlistquery, but you do getitem, then this make 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 [00:25:24](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h25m24s) model methods. which are custom methods. That is setting the global. -The filtering you have a a list of possible filtering. Depending on what you want to do. You might select id, or user, access, level, group, category, [00:25:45](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h25m45s) tags or date. 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. This function variable works well. As well as array, value, repeatable value, and other all those already work very well. You can use them and implement them. The only way for you to [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 it and go look in the code what it has done and where it's placed what. That is why I showed you that this is all 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 I added. I look in the code it says 'State Key' and it's this(JRequest::getint by id) here. We set it is a function variable. It doesn't change or adapt this at all. Then says it must be equal to preacher. What we are doing, since component builder doesn't know where the this variable is going to 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. +The filtering you have a a list of possible filtering. Depending on what you want to do. You might select id, or user, access, level, group, category, [00:25:45](https://www.youtube.com/watch?v=OPuCoxPW35s&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h25m45s) tags or date. 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. This function variable works well. As well as array, value, repeatable value, and other all those already work very well. You can use them and implement them. The only way for you to [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 it and go look in the code what it has done and where it's placed what. That is why I showed you that this is all 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 I added. I look in the code it says 'State Key' and it's this(JRequest::getint by id) here. We set it is a function variable. It doesn't change or adapt this at all. Then says it must be equal to preacher. What we are doing, since component builder doesn't know where the this variable is going to 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. +It 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. Getting more developers involved may possibly improve this long run. + +**Dynamic Get Get Access( Default added)** + +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** + +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. + +**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 basically what dynamic get is for. As you saw we have a main source on the model. Then we have this other one called getpreacher. ???? -It 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. +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.