Updated 014 Adding dynamicGet to a Site View (markdown)
parent
e9196b9400
commit
c9dd1c40fa
@ -2,33 +2,36 @@
|
||||
|
||||
### Checking The Target Dataset
|
||||
|
||||
Hi now that we have the dynamicGet in place, let's add that to a site view and look at the initial implementation. We will go to site view and then click on new, but since we already have that you created, we just going to open it called preacher.
|
||||
Now that we have the dynamicGet in place, let's add it to a site view and look at the initial implementation. Go to site view and click on new. Since we already have what you created, we will just open preacher.
|
||||
|
||||
### Populate Fields From Get's
|
||||
|
||||
You would see there on the right-hand there are 3 fields that you can populate with your dynamicget methods. The first one is where you would add all the custom dynamicgets. There you can add multiple custom dynamicgets. The second one is where you add your main dynamicget as we explained in the dynamicget tutorial. you can add 1 main get method per [00:00:57](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h00m57s) view or site view. Since it's going to be build in the model, either as a getitem or a getitems. It is all depending on the main get whether it's going to be a list or an individual item. Yet you can include custom dynamicgets as many as you like. You also have this data available in your view. These two first fields are used to load the dynamicget to the view.
|
||||
On the right-hand there are three fields you can populate with your dynamicget methods. The first is where you'd add all the custom dynamicgets. There you can add multiple custom dynamicgets. The second is where you add your main dynamicget as we explained in the dynamicget tutorial. You can add one main get method per site view since it will be buildt in the model, either as a getitem or getitems. [00:00:57](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h00m57s) It depends whether the main get it is a list or an individual item. Whatever the case, you may include as many custom dynamicgets as you like. You have this data available in your view. (See video.) These two first fields are used to load the dynamicget to the view.
|
||||
|
||||
### Dynamic Values
|
||||
|
||||
The third one [00:01:37](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h01m37s) is used to display. The possible way that you might want to implement the code of a specific dynamicget option. You'll see that this one displays main gets. This one displays customer gets. This(Dynamic Get) displays both the custom and the main kind of gets. If you select a [00:02:04](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m04s) one of these main gets, sermon(series.id)(getlistquery). You will see that it shows a list printout of the possible ways that you might use the result set. [00:02:32](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m32s) Each of these you can copy by clicking on it. Clicking either right click and copy or you could click on ctrl C and command C to copy respectively the content. Sometimes you might only want to use part of it and not the echo statement included. Then you can click from the area where you want to copy and then before letting go [00:03:05](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m05s) click on control C or command C in a mac to insure you only grab that section of the text. Once you let it go it will select the whole block and then if you copy it, you will copy everything.
|
||||
The third is used to display. [00:01:37](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h01m37s) You might want to implement the code of a specific dynamicget option. This one displays main gets; this one customer gets; this both the custom and the main kind of gets. [00:02:04](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m04s) If you select one of these main gets you will see that it shows a list printout of the possible ways you might use the result set. [00:02:32](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m32s) (You can copy
|
||||
each of these by clicking on it; right click and copy or ctrl C and command C to copy the content.) Perhaps you only want to use part of it and not include the echo statement: click from the area where you want to copy and before letting go click on control C or command C. [00:03:05](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m05s) In a mac once you let it go it will select the whole block; if you copy it then, you will copy everything.
|
||||
|
||||
### Inserting Values Into View
|
||||
|
||||
As you can see we then use this(Dynamic Values) code in the default view to display the data in a PHP [00:03:36](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m36s) fashion. You can also get the customerget here. That one preacher. That value is going to be in this preacher. And if we look here(default view) at the top, that is what we are checking for. Make sure that you have a preacher, and then this block deals with displaying the data related to that information. This one here(see video) [00:04:08](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m08s) checks whether the main items are on the page. Now the main items as you can see is sermons, preacher.id, getlist. If I go down to that sermon preacher, I get list. It shows me that the values are in items. It's an array. I can loop through it and target the the object values. That's what's being done here(default view). We first checking whether it's [00:04:38](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m38s) on the page the values. Then if we see that it is here, we make use of templates to display the various layouts. I will explain in a next tutorial how to use templates in layouts inside of your site view. [00:05:01](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h05m01s) This is just quickly showing you how to connect a dynamic get structure or methods to your view.
|
||||
We use Dynamic Values code in the default view to display the data in a PHP way. [00:03:36](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m36s) You can get the customerget here. The value is going to be in this preacher. (Make sure you have a preacher.) This block deals with displaying the data related to the information. This one here checks whether the main items are on the page. (See video.) [00:04:08](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m08s) The main items are sermons, preacher.id, getlist, etc. If you go down to the sermon preacher, you'd get list; the values are in items. It's an array. You can loop through it and target the object values. That's what's being done here. First check whether the values are on the page. [00:04:38](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m38s) If we see that it is there, we make use of templates to display the various layouts. [00:05:01](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h05m01s)
|
||||
|
||||
Then how to make use of the data that are being passed through to the view. This data structures here on the right in red, is the data structure that you can expect from each one of these(Custom Gets). If I was to take number sermons as the method that I want to see, [00:05:36](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h05m36s) then it shows me that's possibly the way that it will be packed into the data set. It'll be found in this 'numbersermons'. That could change depending on your custom implementation in your components custom coding areas. You might move this data from that position to something else. But the reality is this(Dynamic Values) at least gives you how it would have looked without leaving the [00:06:10](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m10s) normal path.
|
||||
### Making Use of Data Being Passed Through to the View
|
||||
|
||||
This data structure is the data structure you can expect from each one of these Custom Gets. (See video.) If you were to take number sermons as the method you want to see, it shows the way that it might be packed into the data set. [00:05:36](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h05m36s) It'll be found in this 'numbersermons'. It could change depending on the custom implementation in your components custom coding areas. You might move this data from that position to something else. The reality is that Dynamic Values gives you a chance to see how it would have looked without leaving the normal path. [00:06:10](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m10s)
|
||||
|
||||
### Var Dump
|
||||
|
||||
This is just proposing the dataset structure which ideally would be that you would take this(numbersermon) value here, and do this(see video) in the code. Do a var_dump, and then exit, and then do a build and go look at this view to see exactly the structure. [00:06:45](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m45s) If you are finding that this structure that we've shown isn't working exactly as we expected. Often this helps us to map the array and see where what value is found. Same goes with any of the others. You can just grab that area, that you want to peek into. Put it in var_dump. Do a build, go look at this page in the front of your site. You can see exactly the structure of this object here. [00:07:20](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h07m20s) Whether it is an array or array with objects or whatever is placed inside of this value set through the dynamic get method.
|
||||
This is proposing the dataset structure: ideally you'd this value here, and do this in the code. (See video.) Do a var_dump, exit, do a build, and look at the view to see the structure. [00:06:45](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m45s) If you are finding that this structure isn't working as we expected, this might help map the array and see where which value is found. The same goes with any of the others. Grab that area that you want to peek into, place it in var_dump, do a build, and look at the page in the front of your site. You can see the structure of the object here, whether it's an array, an array with objects, or whatever is placed inside this value set through the dynamic get method. (See video.) [00:07:20](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h07m20s)
|
||||
|
||||
### Gets In The Code eg: Preacher.php
|
||||
|
||||
Now I just want to quickly peek at the way that these(Custom Gets) methods are actually becoming available in your view by going to the code by looking at some of the implementations that we've done. As you can see we've gone to the front of the site [00:07:55](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h07m55s) sermon distributor, models. We've open preacher model, use the preacher model. As you scroll down you see that there's a getListquery. This getlistquery gets sermon as the 'a' table, and then [00:08:18](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m18s) series as the 'c' table, preacher is the 'd' and categories as the 'b' table. Then it looks for value in id. Then sets it equal(=) to preacher. Then ensures that [00:08:41](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m41s) the person has access level to the item that's published, and then returns it. That is the getListquery in the model. If we go back to our interface, you will see that we have sermon (preacher.id)(getlist) as the main. [00:09:06](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m06s)
|
||||
Let's look at how Custom Gets methods are becoming available in your view by going to the code and looking at some of the implementations that we've done. We've gone to the front of the site. (See video.) [00:07:55](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h07m55s) We open and use the preacher model. As you scroll down you see that a getListquery. This getlistquery gets sermon as the 'a' table, series as the 'c' table, preacher is the 'd' table, and categories as the 'b' table. [00:08:18](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m18s) Now it looks for value in id, sets it equal to preacher, ensures that the person has access level to the item that's published, and returns it. [00:08:41](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m41s) That is the getListquery in the model. If we go back to our interface, we have sermon (preacher.id)(getlist) as the main. [00:09:06](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m06s)
|
||||
|
||||
### Looking At The Dynamic Get
|
||||
|
||||
I've opened that dynamic get here. And you can see that sermon is set as 'a' the main table. If you open here(Join View Table - Add) you see that series is set as 'c' the only looking for those(selection) values. Preacher is set as 'd', only those(selection) values. Statistics 'e', it's a list. [00:09:36](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m36s) It is multiple. These(preacher, series) that are single are part of the listquery. Where as the multiple of it will have its own method. We will look at that quickly, and then we see in the Join DB table - add that we have category as single, as 'b' those values. Going back to the code. [00:10:01](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m01s) This is the getListquery, in the getitem after we have received the items, we look through them and then in this function here getSermonstatistics and then a generated string(Fcff_E) to ensure no conflicting with other methods on the page. Puts the values in 'id sermonsstatisticsE'. [00:10:30](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m30s) That's where the values are placed. We have a custom method here. Like we shown in the dynamic get you can add custom methods, and returns the items to the page.
|
||||
I've opened that dynamic get here. Sermon is set as 'a,' the main table. If you open Join View Table - Add, series is set as 'c' looking for selection values. Preacher is set as 'd', only selection values. Statistics 'e' is a list. It is multiple. [00:09:36](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m36s) These(preacher, series) single ones are part of the listquery whereas the multiple of it would have its own method. We will look at that quickly, and then we see in the Join DB table - add that we have category as single, as 'b' those values. Going back to the code. [00:10:01](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m01s) This is the getListquery, in the getitem after we have received the items, we look through them and then in this function here getSermonstatistics and then a generated string(Fcff_E) to ensure no conflicting with other methods on the page. Puts the values in 'id sermonsstatisticsE'. [00:10:30](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m30s) That's where the values are placed. We have a custom method here. Like we shown in the dynamic get you can add custom methods, and returns the items to the page.
|
||||
|
||||
### Preacher view.html.php Generated Code
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user