From ca6f911667a374258710e5dc84b5d0f5fdc2987e Mon Sep 17 00:00:00 2001 From: Amigo <49749100+aamigo@users.noreply.github.com> Date: Wed, 2 Oct 2019 13:56:15 +0200 Subject: [PATCH] Updated 069 Join Fields in the admin list view with field relations (markdown) --- ...n-the-admin-list-view-with-field-relations.md | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/069-Join-Fields-in-the-admin-list-view-with-field-relations.md b/069-Join-Fields-in-the-admin-list-view-with-field-relations.md index ad5afcb..038fc42 100644 --- a/069-Join-Fields-in-the-admin-list-view-with-field-relations.md +++ b/069-Join-Fields-in-the-admin-list-view-with-field-relations.md @@ -71,8 +71,20 @@ I think best to demonstrate is, first used the Concatenation option which we can [00:19:07](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h19m07s) -Going into the code, we open the body. You'll see the JCB added the
. There is a
, there's a
. There's the portion 'escape($item->email); ?>' of code that JCB build. It really build all of this. It's still built a link to the preacher. It's still built this as well. If this 'escape($item->email); ?>' was going to be a link to another view, it will produce that code. Checking the permissions and everything. Which is really what makes [00:19:43](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h19m43s) This areas implementation quite exciting. Because it still takes care of the hard work of producing the code needed to display the value. If you pick up any behaviors in this new feature that is unexpected, please give us a heads up on Github or open an issue. We will try and address it as quick as we can. +Going into the code, we open the body. You'll see the JCB added the
. There is a
, there's a
. There's the portion 'escape($item->email); ?>' of code that JCB build. It really build all of this. It's still built a link to the preacher. It's still built this as well. If this 'escape($item->email); ?>' was going to be a link to another view, it will produce that code. Checking the permissions and everything. Which is really what makes [00:19:43](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h19m43s) This areas implementation quite exciting. Because it still takes care of the hard work of producing the code needed to display the value. If you pick up any behaviors in this new feature that is unexpected, please give us a heads up on Github and open an issue. We will try and address it as quick as we can. This is the new feature of combining admin view values [00:20:19](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h20m19s) in a very easy way. It could have been done previously with some custom scripting, but this helps you and I'm sure makes it easy for you to just select the field you want to target. You first need to add the fields that you are already going to show in the list view and then select the field you want to join to it. I expected that you will understand that, but I realize I must mention that separate. +### Preacher Field - Two Field - Name And Description + +[00:21:17](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h21m17s) + +If we go into the Preacher fields area, you'll see we have two fields the Name(text), shown in list, and the Description shown in list. We don't make any changes. We don't say that the email and then website must also show in the list view. Only the fields that are not showing in the list view, show in the relationship view as Joint options. That's a heads up. What is exciting though, you can do a filter or a search on these fields that are not going to be placed but you know you are later going to select them as relationships. [00:21:47](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h21m47s) JCB will end up creating the filter and make it searchable. Even if it's a link to another page you can click this to be a link and it will generate the link. I think it is amazing knowing that it's going to set all the permissions in place and everything else. Maybe I should demonstrate that quickly. + +### Demonstration - Combining Preacher With Name Row + +[00:22:15](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h22m15s) + +In the Sermons area we will see that we have a Preacher table and a Name table. We have these two links 'Ten shekels and a shirt and Paris Reidhead', this 'Paris Reidhead' will open the Preacher, the same as opening it from the Preacher list view and then this 'Ten shekels and a shirt' is going to open the Sermon. This is going to be easy because [00:22:45](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h22m45s) we can decide we have so many rows, let's combine the Preacher with the Name row. Yet we want to retain the link as it is working. We want to retain the option to filter by the Preacher. Let's show you how easy it is to do that. We'll go to the Sermons list View or admin view and then again to the fields, click on create fields relations, before we are going to do that, [00:23:20](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h23m20s) I first need to remove the Preacher from the list. We are first going to go to where we selected the fields. That needs to be linked to the admin list view. ???? -This is the new feature of combining admin view values [00:20:19](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h20m19s) in a very easy way. It could have been done previously with some custom scripting, but this helps you and I'm sure Makes it easy for you to just select the field you want to Target of course that means You first need to add the fields that you are ready going to show in the list View And then select the field you wanna join to it That's sort of I expected you understood maybe that but I realize I must mention that separate [00:20:53](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h20m53s) So that means if we go into the preacher Fields area you'll see That We actually just got two Fields the name As shown in list And the description shown in list So here we don't make any changes we don't say that the email and then Website Must also show in the list View In fact [00:21:17](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h21m17s) Only the fields that I'm not showing in the list View Show show in the relationship view as joint options So that's just a heads up What is exciting though as you can Actually Do a a filter And a Yeah you can do a filter or a search On these Fields that are not going to be placed but you know you gonna later select them as relationships [00:21:47](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h21m47s) And then the end up creating JCB will in upgrading the filter And make it searchable at even if it's a link to To another page you can click this to be a link And then it will generate the link Which is I think amazing knowing that it's gonna set that all the permissions in place And everything else Ok well maybe I should Demonstrate that Just quickly [00:22:15](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h22m15s) So here in the sermons area We see that we have a Preacher table and we gotta name table So That means we can actually We have these two links this one will open the preacher As We know Same as opening it from the preacher list view and then this one's gonna open the sermon So This is going to be easy because now [00:22:45](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h22m45s) We can decide Ok we got so many rows here let's Combine the preacher With the name row And yet we wanna retain this link As it is working now and we wanna retain the option to actually filter by The preacher So let's show you how easy it is to do that So we'll go to the sermons list View or admin viewing and then Also again to the fields and click on create fields relations in this ad o wait before we We do that [00:23:20](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h23m20s) I first need to remove The preacher From the list so we first gonna go to the Where we selected the fields That needs to be linked To the List the admin list View And the one we want to remove Is the preacher value So it's this one [00:23:42](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h23m42s) Sermon preacher we gonna say no Don't add it and when you do that is gonna wipe out all the links that usually Should not be selected if it's not a listview But since we still wanted to be a link And we still wanted to be a filter We gonna leave those checked And then click save and close So now Getting back to this page And going to Fields we'll see that [00:24:10](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h24m10s) The the preacher now Is No longer going to show the list View But it's still Going to be A filter in a link And if you compile now it won't show up at all You still need to now go and select the relations area click on new And then select name [00:24:33](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h24m33s) Here You would now Need to select The sermon preacher And then View And then Well we could either say We wanna do this ourselves Or [00:24:50](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h24m50s) We could Use glue Which in this case I'm just gonna use a space just an empty space like that And save and close And then we compile Install And then refresh the sermon page we see that now They are [00:25:21](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h25m21s) Two links here The one is to open the Actual Sermon and the other one is opening the It's going to open the preacher So if we click on it it still behaves as before the preacher gets opened we closed again And we back here and we still have the preacher filter Here at the bottom of our page As we had it before [00:25:48](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h25m48s) And so This is really Great We can also then open here And All is working as expected Now as easy as it was To combine these two values into one column While still retaining the actual links and everything surrounding this value having a Dynamically get the name [00:26:16](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h26m16s) Because obviously in the table it's taught the ID only And now showing it here it means it's actually remapped it in the database so let me show you that So we open the sermons Model and we scroll down We'll see here in the the list query It's still Maps the preacher table in And Builds the connection on the ID in the preacher And still selects [00:26:49](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h26m49s) The preacher name Then going to the view of that Sermons We see if you scroll down Here It has Produced this chunk Of code For the for the preachers name And this chunk of code [00:27:14](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h27m14s) For the Sermon name So it still does all the Producing of the HTML code and all the permissional checking whether Does this user actually have The edit permission to To change this value Of the specific preacher [00:27:37](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h27m37s) So yes and yet it's showing the preacher name As the linking up in the database was done So it's quite exciting I really Hope that you would find it as useful as I am already doing And like I said if you discover anything not to work as expected Please do contact me and on GitHub open up a issue And we will Take it from there. Thanks for watching. + +And the one we want to remove Is the preacher value So it's this one [00:23:42](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h23m42s) Sermon preacher we gonna say no Don't add it and when you do that is gonna wipe out all the links that usually Should not be selected if it's not a listview But since we still wanted to be a link And we still wanted to be a filter We gonna leave those checked And then click save and close So now Getting back to this page And going to Fields we'll see that [00:24:10](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h24m10s) The the preacher now Is No longer going to show the list View But it's still Going to be A filter in a link And if you compile now it won't show up at all You still need to now go and select the relations area click on new And then select name [00:24:33](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h24m33s) Here You would now Need to select The sermon preacher And then View And then Well we could either say We wanna do this ourselves Or [00:24:50](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h24m50s) We could Use glue Which in this case I'm just gonna use a space just an empty space like that And save and close And then we compile Install And then refresh the sermon page we see that now They are [00:25:21](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h25m21s) Two links here The one is to open the Actual Sermon and the other one is opening the It's going to open the preacher So if we click on it it still behaves as before the preacher gets opened we closed again And we back here and we still have the preacher filter Here at the bottom of our page As we had it before [00:25:48](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h25m48s) And so This is really Great We can also then open here And All is working as expected Now as easy as it was To combine these two values into one column While still retaining the actual links and everything surrounding this value having a Dynamically get the name [00:26:16](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h26m16s) Because obviously in the table it's taught the ID only And now showing it here it means it's actually remapped it in the database so let me show you that So we open the sermons Model and we scroll down We'll see here in the the list query It's still Maps the preacher table in And Builds the connection on the ID in the preacher And still selects [00:26:49](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h26m49s) The preacher name Then going to the view of that Sermons We see if you scroll down Here It has Produced this chunk Of code For the for the preachers name And this chunk of code [00:27:14](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h27m14s) For the Sermon name So it still does all the Producing of the HTML code and all the permissional checking whether Does this user actually have The edit permission to To change this value Of the specific preacher [00:27:37](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h27m37s) So yes and yet it's showing the preacher name As the linking up in the database was done So it's quite exciting I really Hope that you would find it as useful as I am already doing And like I said if you discover anything not to work as expected Please do contact me and on GitHub open up a issue And we will Take it from there. Thanks for watching.