From ccbabc659c2e65e196f0d8fd1ea9170edda8bfe5 Mon Sep 17 00:00:00 2001 From: Amigo <49749100+aamigo@users.noreply.github.com> Date: Mon, 3 Jun 2019 17:10:52 +0200 Subject: [PATCH] Updated 014 Adding dynamicGet to a Site View (markdown) --- 014-Adding-dynamicGet-to-a-Site-View.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/014-Adding-dynamicGet-to-a-Site-View.md b/014-Adding-dynamicGet-to-a-Site-View.md index 4c5ff0e..bb0bcb9 100644 --- a/014-Adding-dynamicGet-to-a-Site-View.md +++ b/014-Adding-dynamicGet-to-a-Site-View.md @@ -1 +1,12 @@ -Hi now that we have the dynamic Get 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 gonna open it called preacher You would see there on the right-hand there are 3 Fields that you can Populate with your Dynamic get methods the first one is where you would add All the custom Dynamic gets and there you can add multiple custom dynamic gets The second one is where you add your main Dynamic get as we explained in the dynamic get 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 get item or a get items it is all depending on the Main get weather it's gonna be a list or just an An individual item Yet you can include Dynamic Gets Custom Dynamic gets as many as you like You also have this data available in your view So these two first fields are used to load The Dynamic get to the view 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 Dynamic get option You'll see that This one only displays Possible main Gets this one only this place customer gets Where is this displays both The custom and the main kind of Gets Now If you select a [00:02:04](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m04s) let's go to One of these Main Gets Sermon This one here You see that it shows us A list Print out 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) Obviously each of these you can copy by clicking in it and then clicking on either right click And Copy or you could click on ctrl V 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 pick 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 Obviously if you copy it you will copy everything As you can see We then use This code in our 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 the customer get here let me show you that one preacher Like you see it says that that Value is gonna be in this preacher And if we look here at the top that is what we are checking for here Make sure that you have a Preacher And then this block Basically deals with displaying the data related to that Information This one here [00:04:08](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m08s) Checks whether the main items are on the on the page and now the main items as you can see Is sermons preacher ID get list So if I go down to that sermon preacher I get List You see that again it shows me that the values are in items And it's in array So I can loop through it and target the the object values And that's what's being done here 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 use make use of templates to to display the various Layouts And 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) But this is just quickly showing you how to connect A dynamic get Structure or Methods to your view And then how to make use of the data that are being passed through to the view So this data structures here on the right in red Is basically the the data structure that you can expect From each one of these so 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 That's possibly the way that it will be packed into the data set So it'll be found in this number sermons is how Now that could change Depending on your custome implementation In your components custom coding areas you might move this data from that Position to something else But the reality is this at least gives you how it would have looked without you You know I'm leaving the [00:06:10](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m10s) The normal Path So this is just Proposing the dataset structure Which ideally would be that you would take this value here And Maybe do this in the code Do a var_dump And then exit And then Basically 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 sort a 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 in the front of your site And you can see exactly the structure of this This object here [00:07:20](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h07m20s) Whether it is an array with objects or whatever Is placed inside of this value set through the dynamic get method Now I just want to quickly Peek at the Way that these methods are actually becoming available in your view by going to the code And just looking at Some of the implementations that we've done Ok 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 And we've opened The preacher model Use the preacher model And As you scroll down you see that there's a get list query This get list query 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 is the Sorry C D B Is the B table And then it looks for a value in ID And then Sets it equal to preacher And in sure that it [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 So that is the Get List query in the model Have you go back to our interface you see that we have sermon preacher ID get list as the main [00:09:06](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m06s) And I've opened that Dynamic get here let me just see where is it And you can see that Sermon is set as A the main table And if you open here you see that series is set as C the only looking for those values Preacher said is d only those values Statistics E But it's a list [00:09:36](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m36s) it is Multiple These that are single are part of the list query where is the multiple of it will have its own object sorry it's Method we will Look at that quickly And then We see in the DB table That we have category a single as B Only those values So going back to the code [00:10:01](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m01s) This is the get list query in the get item After we have received the items We look through them And then in this function here get Sermon statistics and then a A generated string Randomly generated string to ensure No conflicting with other methods on the page Puts the values in ID sermons statistics e [00:10:30](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m30s) So that's where the values of place And then basically we have a custom Method here like be shown in the dynamic get you can add custom methods And then returns the items to the page And in the page You have a A file That is called View [00:10:55](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m55s) Sorry view HTML dot. PHP If you open this File you see that there is a get items Method being used to place the items in items And so At the moment we are actually in the view at this stage And that means you can access This set of values Inside of that Class field [00:11:26](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m26s) And so if we go back to our Component Builder You would see if we were to select That method There is the items Corresponding to our code And so we know that the ID in the asset ID in all these are in there if you scroll down You see that there is it sermons is too sticky see it there So that means In the array there is a [00:12:03](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m03s) key value Which has another set of array values in it So you can target these data sets By corresponding pointing Values So that is just looking at the main get Now if we were to look at The other custom get [00:12:28](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m28s) That is been added We'll see that here's preacher Which is a custom get or custom method That is been added And It also has its set of Values and it's database structure and remember we said that we want it to be Link to the preachers ID So can I check for the ID [00:12:53](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m53s) And then Set it to ID And returns the result Same goes with the number of downloads It's also custom method That said To this view because of the custom get that was added And here is the number sermons And we go back to our view dot HTML dot php file We see that those values are respectively being added [00:13:21](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m21s) To preacher Number downloads and number sermons And you can actually use these values in the view by targeting with this number Sermons Now the view itself is As you should know inside of the template folder Under the views preacher And this Main View as we call it all the default view is where that code that we on the page that we looking at right now [00:13:50](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m50s) Being placed All these others are the templates that are extending the site View And they possibly are extended through layouts that are available in the layouts folder So We are we are now just looking at adding The custom get methods to the page in our next to tutorial we are going in depth about adding templates to your Custom Site View And making use of these data sets [00:14:24](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m24s) So That is how you link them your first create the custom get then you come here you link these So these are the linking Fields and these are just so that you can see the code snippets are making use of these fields Respectively And That is custom Gets added to site view Thank you for watching +# ADDING DYNAMICGET TO A SITE VIEW + +**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. + +**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 dynamicgets Custom Dynamic gets as many as you like You also have this data available in your view So these two first fields are used to load The Dynamic get to the view 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 Dynamic get option You'll see that This one only displays Possible main Gets this one only this place customer gets Where is this displays both The custom and the main kind of Gets Now If you select a [00:02:04](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m04s) let's go to One of these Main Gets Sermon This one here You see that it shows us A list Print out 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) Obviously each of these you can copy by clicking in it and then clicking on either right click And Copy or you could click on ctrl V 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 pick 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 Obviously if you copy it you will copy everything As you can see We then use This code in our 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 the customer get here let me show you that one preacher Like you see it says that that Value is gonna be in this preacher And if we look here at the top that is what we are checking for here Make sure that you have a Preacher And then this block Basically deals with displaying the data related to that Information This one here [00:04:08](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m08s) Checks whether the main items are on the on the page and now the main items as you can see Is sermons preacher ID get list So if I go down to that sermon preacher I get List You see that again it shows me that the values are in items And it's in array So I can loop through it and target the the object values And that's what's being done here 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 use make use of templates to to display the various Layouts And 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) But this is just quickly showing you how to connect A dynamic get Structure or Methods to your view And then how to make use of the data that are being passed through to the view So this data structures here on the right in red Is basically the the data structure that you can expect From each one of these so 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 That's possibly the way that it will be packed into the data set So it'll be found in this number sermons is how Now that could change Depending on your custome implementation In your components custom coding areas you might move this data from that Position to something else But the reality is this at least gives you how it would have looked without you You know I'm leaving the [00:06:10](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m10s) The normal Path So this is just Proposing the dataset structure Which ideally would be that you would take this value here And Maybe do this in the code Do a var_dump And then exit And then Basically 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 sort a 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 in the front of your site And you can see exactly the structure of this This object here [00:07:20](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h07m20s) Whether it is an array with objects or whatever Is placed inside of this value set through the dynamic get method Now I just want to quickly Peek at the Way that these methods are actually becoming available in your view by going to the code And just looking at Some of the implementations that we've done Ok 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 And we've opened The preacher model Use the preacher model And As you scroll down you see that there's a get list query This get list query 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 is the Sorry C D B Is the B table And then it looks for a value in ID And then Sets it equal to preacher And in sure that it [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 So that is the Get List query in the model Have you go back to our interface you see that we have sermon preacher ID get list as the main [00:09:06](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m06s) And I've opened that Dynamic get here let me just see where is it And you can see that Sermon is set as A the main table And if you open here you see that series is set as C the only looking for those values Preacher said is d only those values Statistics E But it's a list [00:09:36](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m36s) it is Multiple These that are single are part of the list query where is the multiple of it will have its own object sorry it's Method we will Look at that quickly And then We see in the DB table That we have category a single as B Only those values So going back to the code [00:10:01](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m01s) This is the get list query in the get item After we have received the items We look through them And then in this function here get Sermon statistics and then a A generated string Randomly generated string to ensure No conflicting with other methods on the page Puts the values in ID sermons statistics e [00:10:30](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m30s) So that's where the values of place And then basically we have a custom Method here like be shown in the dynamic get you can add custom methods And then returns the items to the page And in the page You have a A file That is called View [00:10:55](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m55s) Sorry view HTML dot. PHP If you open this File you see that there is a get items Method being used to place the items in items And so At the moment we are actually in the view at this stage And that means you can access This set of values Inside of that Class field [00:11:26](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m26s) And so if we go back to our Component Builder You would see if we were to select That method There is the items Corresponding to our code And so we know that the ID in the asset ID in all these are in there if you scroll down You see that there is it sermons is too sticky see it there So that means In the array there is a [00:12:03](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m03s) key value Which has another set of array values in it So you can target these data sets By corresponding pointing Values So that is just looking at the main get Now if we were to look at The other custom get [00:12:28](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m28s) That is been added We'll see that here's preacher Which is a custom get or custom method That is been added And It also has its set of Values and it's database structure and remember we said that we want it to be Link to the preachers ID So can I check for the ID [00:12:53](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m53s) And then Set it to ID And returns the result Same goes with the number of downloads It's also custom method That said To this view because of the custom get that was added And here is the number sermons And we go back to our view dot HTML dot php file We see that those values are respectively being added [00:13:21](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m21s) To preacher Number downloads and number sermons And you can actually use these values in the view by targeting with this number Sermons Now the view itself is As you should know inside of the template folder Under the views preacher And this Main View as we call it all the default view is where that code that we on the page that we looking at right now [00:13:50](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m50s) Being placed All these others are the templates that are extending the site View And they possibly are extended through layouts that are available in the layouts folder So We are we are now just looking at adding The custom get methods to the page in our next to tutorial we are going in depth about adding templates to your Custom Site View And making use of these data sets [00:14:24](https://www.youtube.com/watch?v=vEJZe6XqHJE&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m24s) So That is how you link them your first create the custom get then you come here you link these So these are the linking Fields and these are just so that you can see the code snippets are making use of these fields Respectively And That is custom Gets added to site view Thank you for watching