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 8aefbf4..4e34971 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 @@ -49,10 +49,21 @@ Let's make another change. Instead of using the default glue option, we want to Another thing. You can only target the name list field once. You cannot add it a second time like this(see video) and say here we are going to do it again. Using maybe some other values to also target it in some way. [00:13:52](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m52s) You cannot do that. Only one of them will get implemented. The other one will be dropped. It's a limitation I know. Believe me this feature as it is now is already stunning and able to achieve quite impressive results. Here we have it, we've adapted it. It will only show an email or a web address if there is one set. If there is none set, it won't show any. That's the expected result. Let's save this and see it in action. [00:14:31](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m31s) We will compile it and install. There we have it. The preacher showing up with an email address. - ### Create Preacher Without Email Address [00:14:44](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m44s) +Let's create one without an email address. We created one with no email address. If you will see there's none. Let's add a web address. Let's close again. There is nothing not even a comma, but as you will see this is a link. The whole thing is a link. That might not be exactly what you want. Let's add a web address. Save and close. Because your web address was a little bit too long, it created a pop-up. [00:15:26](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15m26s) All that can be changed. Let me do something else. Let's use a shorter address. Save and close. That looks more acceptable. It detects whether there's an email or a web address. If there's none it shows none. That was with this new combine feature. + +### Targeting The View + +[00:15:53](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15m53s) + +Let's do something even more interesting. Again we go and open Preacher area clicking the icon underneath Preacher. This is a shortcut. Instead of targeting the model, we are going to target the View. This is where it really gets interesting. Because this little place holder called field=199 is a chunk of code as I explained initially in the beginning. Where we are saying [00:16:30](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m30s) instead of targeting the actual value database value, you are targeting the produced code which JCB builds. The HTML block for that specific field. I would also encourage you removing the comment, this comment ' Name;[1222]=>Email(not required);[280]=>Website ->' that shows you the name, the email and the web address. [00:16:57](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m57s) I would also encourage you to once you have seen it just remove it. We might at a later stage take the comment and added underneath the box that it is clearly nowhere in the way. It is for you to know that this portion is for the email and the website address. Again I want to add a little bit dynamic Script. I need to keep in mind that I'm in HTML. [00:17:31](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h17m31s) If I wanted to add PHP I will need to do the correct PHP tags and all the rest of it. That means you can target the item value. You can remove this '[field=199]
[field=1222]
[field=280]' and work with the item value. But this [field=199] little placeholder will produce the whole [00:18:03](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h18m03s) block of code. If it's going to be a dynamic link, or something like that. It'll produce all of that for you if it's a custom field which links to another View. Then all of that can still be produced in this dynamic placeholder [field=1222] . But you can remove all of this and you can have it echo out anything which you just have to code. + +### Demonstration + +[00:18:32](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h18m32s) + ???? -Let's create one without an email address. We created one with no email address. If you will see there's none. Let's add a web address. Let's close again. There is nothing not even a comma, but as you will see this is a link. The whole thing is a link. That might not be exactly what you want. Let's add a web address. Save and close. Because your web address was a little bit too long, it created a pop-up. [00:15:26](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15m26s) Now all that can be changed But let me just Do something else Let's use a shorter address Save and close And now there you have it That looks more acceptable And so it detects now whether there's an email or a web address and if there's none it shows none So that was now with this new combine Feature [00:15:53](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15m53s) So let's, let's do something even more interesting So again we go and open that area clicking this icon This is sort of a shortcut And now instead of targeting the model We gonna target The View And this is where it really gets interesting Because now this little place holder called field=199 Is basically a chunk of code as I explained Initially in the beginning Where we are saying [00:16:30](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m30s) Ok Instead of Targeting the actual value database value You are now targeting the produced code which JCB builds The html block For that specific field So We can now also I would also encourage you removing the comment this is the comment that shows you that that is the name That's the email And that's the web address [00:16:57](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m57s) So I would also encourage you to once you seen it or just remove it we might at a later stage Take the comment and added underneath the box so that it Clearly is nowhere In the way But it is for you to just sort of know that this chunk Is for the email and this is for the website Address ok so again I want to add a little bit Dynamic Script here But I need to keep in mind that I'm actually in HTML [00:17:31](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h17m31s) So if I wanted to add PHP here I actually need to Do the correct PHP tags And all the rest of it Ok And that means you can actually Target the item value You can remove this and work with the actual item value But this little placeholder will produce the whole [00:18:03](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h18m03s) Block of code which if it's going to be a dynamic link Or something like that It'll produce all of that for you So if it's a If it's an A custom field which links to a to another View Then all of that can still be produced in this Sort of dynamic placeholder here But you can remove this all of this and you can Yeah have it [00:18:27](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h18m27s) Echo out anything So which you just have to code of course I think Best to demonstrate is first used in concatenation option And which would just put a break between the values And then save and close And compile install So we refresh this area And now we see that This value is a link but the other two [00:19:01](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h19m01s) It's actually just text And that's exactly What we wanted to achieve Going into the code We open the body And you'll see The JCB added the brakes There is a break There's a break And there's the chunk of code that JCB build [00:19:22](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h19m22s) So It really build all of this It's still built a link to the preacher And then It's still built this As well So if this was going to be a link to another View It will produce that code Checking again 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 actual code needed to display the value If you pick up any behaviours in this new feature that sort of unexpected Then please give us a heads up on Github open an issue And we will try and address it as quick as we can Again thank you for watching 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 sort of 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. +I think best to demonstrate is, first used the Concatenation option which we can put a
between the values. Save and close. Compile, install. We will refresh this area. And now we see that This value is a link but the other two [00:19:01](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h19m01s) It's actually just text And that's exactly What we wanted to achieve Going into the code We open the body And you'll see The JCB added the brakes There is a break There's a break And there's the chunk of code that JCB build [00:19:22](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h19m22s) So It really build all of this It's still built a link to the preacher And then It's still built this As well So if this was going to be a link to another View It will produce that code Checking again 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 actual code needed to display the value If you pick up any behaviours in this new feature that sort of unexpected Then please give us a heads up on Github open an issue And we will try and address it as quick as we can Again thank you for watching 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 sort of 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.