Updated 007 Admin Views (markdown)

Amigo 2019-05-28 08:42:20 +02:00
parent 9f98aa8c4b
commit 2e2a2616b7

@ -47,22 +47,17 @@ The tab structure. We call these tabs. (See video.) [00:19:27](https://www.youtu
In 'Preacher' I set up two tabs: one called 'Details' and one called 'Sermons.' [00:20:32](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h20m32s) So there are two tabs in 'Preacher' which means that if you were to open the 'Preacher' back end view the first one would be called settings and the second one will be called sermons.
* **Fields Linking**
When you create fields [00:20:53](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h20m53s) you'd see a column here called tab, and you then will select the number. Now the tabs are number from one to whatever. We don't start at zero although that might have made more sense for programmers we started with one. So first tab, second tab, and because we are using [00:21:15](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h21m15s) a place different from the tabs. We don't use the names. So you need to remember that this is tab one, this is tab two. So when you set up a field you need to tell us in which tab you want to place that field. So that is what this tab number here is all about. [00:21:35](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h21m35s) Now you might say but where is tab two's information because they are sermons right. Well because of the fact that sermons is an actually a table on its own. If we go out here we will see that there is a admin view called sermon, and it has its own back end view, [00:22:02](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h22m02s) and it has its own structure. So how can I get the sermons that is only related to this preacher to be showing in the second tab called sermons? Well we created a thing called linked views.
When you create fields [00:20:53](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h20m53s) you'd see a column here called tab, and you then will select the number. Now the tabs are number from one to whatever. We don't start at zero although that might have made more sense for programmers we started with one. So first tab, second tab, and because we are using [00:21:15](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h21m15s) a place different from the tabs. We don't use the names. So you need to remember that this is tab one, this is tab two. So when you set up a field you need to tell us in which tab you want to place that field. So that is what this tab number here is all about. [00:21:35](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h21m35s) Now you might say but where is tab two's information because they are sermons right. Well because of the fact that sermons is actually a table on its own. If we go out here we will see that there is a admin view called sermon, and it has its own back end view, [00:22:02](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h22m02s) and it has its own structure. So how can I get the sermons that is only related to this preacher to be showing in the second tab called sermons? Well we created a thing called linked views.
* **Fields Linked Views**
Now linked views is the place where this is done. [00:22:25](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h22m25s) So basically I selected sermon as the view, I said it should be placed in the second tab, and in child key, is preacher. So if I think about sermons which is the child, sermon is the child, preacher is the parent. So you would always think of the parent as this the view in whic Then you'd see publishing and permission. So that's how it would look.h you are the moment you are setting up the linked [00:22:49](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h22m49s) view. So that if you are in preacher the parent is preacher, if you are in sermons, the parent is sermon. So depends on which view you are busy editing. And so here when we talk about the child key, this would be the database field name [00:23:10](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h23m10s) that is to be looked at, and the parent field name, that should be found inside of preachers. So when we look at preachers you would let's go back to sermon. We got sermon open here and if I open this fields, Well I don't need to open it here in fact let me use another place. [00:23:38](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h23m38s) It is easier to see.
Now linked views is the place where this is done. [00:22:25](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h22m25s) So basically I selected sermon as the view, I said it should be placed in the second tab, and in child key, is preacher. So if I think about sermons which is the child, sermon is the child, preacher is the parent. So you would always think of the parent as the view in which you are, the moment you are setting up the linked view. [00:22:49](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h22m49s) So that if you are in preacher the parent is preacher, if you are in sermons, the parent is sermon. So it depends on which view you are busy editing. And so here when we talk about the child key, this would be the database field name [00:23:10](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h23m10s) that is to be looked at, and the parent field name, that should be found inside of preachers. So when we look at preachers you should go back to sermon. [00:23:38](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h23m38s)
Let's go to fields you will see that there is a field called name. There is a field called preacher. This is the field that we want [00:24:10](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h24m10s) connected to with each other right. So to get the sermons that belongs to that preacher, we need to get the ID of this field. Now that is a custom field. And we said that we are going to look at custom fields only after explaining the admin views. So I'm going to go into detail now but I'm going to open that field none the less and I'm going to show you that its name is preacher. [00:24:35](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h24m35s) And because that field will be connected to sermon it means that in the database the ID which is the key field is going to be saved in preacher. So that means the ID of the preacher is saved inside of the preacher column, in the database. [00:24:55](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h24m55s) Now let me show you that in the database itself, so here in the database with sermon distributor and I'm opening sermons and you would see that we would scroll until we see preacher. And it has ID's in it and those are the IDs of the preacher's themselves. So if I was to go to preacher, it basically means that we are linking [00:25:24](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h25m24s) to this ID here. So going back to our linked view concept, that means the child database table, in which the ID of this preacher must be found is in preacher. [00:25:43](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h25m43s) The parent key would be this preachers ID and so by doing that, the linked view will only show the sermons that are related to this specific preacher. And that is how the linked views can be linked. If you didn't select these correctly, it won't load all of them [00:26:05](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h26m05s) It won't work well. So there needs to be that tight relationship between the parent and the child view. So there is also a way to actually link from an array so let's say [00:26:23](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h26m23s) the person is able to select more than one preacher, there is a way for you to also type that, but that would all be dealt with in advanced concepts. I could explain some of it here but let me show you that would be one of the syntax(>) to use [00:26:48](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h26m48s) But like I said I think possibly I need to deal with this in advanced concepts because who will know to look for the answer in this video or tutorial. So we'll stay with the basics here. So the basic way of linking another view would be to select that view from this drop down. Then say in which tab it should display. Then [00:27:12](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h27m12s) what is the child database table in which to look, what is the parents value to use to build a relationship. And then this add new button yes or no, is basically when you look at fields here, you see it has a 'new' button. [00:27:38](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h27m38s) So you can in that switch (add new button) decide whether it should show it or not. I should tell you that if you say yes and you have in that view created the correct permissional of structure for whether somebody can create an item you can control the display of that 'new" button [00:28:02](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h28m02s) with just setting the permission of that users specific group. So if that user isn't in a group that doesn't have permissions to create new items, for in this example, for preachers or for sermons, then that 'new' button will also not show up. So we have that permissional wrapped around that button's display methods. [00:28:26](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h28m26s)
If you go to fields you will see that there is a field called 'name'. There is a field called 'preacher'. This is the field that we want [00:24:10](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h24m10s) connected with each other. So to get the sermons that belongs to that preacher, we need to get the ID of this field. Now that is a custom field. And we said that we are going to look at custom fields only after explaining the admin views. So I'm going to go into detail now but I'm going to open that field none the less and I'm going to show you that its name is preacher. [00:24:35](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h24m35s) And because that field will be connected to sermon it means that in the database the ID which is the key field is going to be saved in preacher. So that means the ID of the preacher is saved inside of the preacher column, in the database. [00:24:55](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h24m55s) Now let me show you that in the database itself, so here in the database with sermon distributor and then open sermons and scroll until we see preacher. And it has ID's in it and those are the IDs of the preacher's themselves. So if I was to go to preacher, it basically means that we are linking [00:25:24](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h25m24s) to this ID here. So going back to our linked view concept, that means the child database table, in which the ID of this preacher must be found is in preacher. [00:25:43](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h25m43s) The parent key would be this preachers ID and so by doing that, the linked view will only show the sermons that are related to this specific preacher. And that is how the linked views can be linked. If you didn't select these correctly, it won't load all of them [00:26:05](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h26m05s) It won't work well. So there needs to be that tight relationship between the parent and the child view. So there is also a way to actually link from an array so let's say; [00:26:23](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h26m23s) the person is able to select more than one preacher, there is a way for you to also type that, but that would all be dealt with in advanced concepts. I could explain some of it here but let me show you what would be one of the syntax(>) to use. [00:26:48](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h26m48s) Possibly I need to deal with this in advanced concepts. So the basic way of linking another view would be to select that view from this drop down(under Sermons). Then say in which tab it should display. Then [00:27:12](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h27m12s) what is the child database table in which to look, what is the parents value to use to build a relationship. And then this add new button yes or no, is basically when you look at fields here, you see it has a 'new' button. [00:27:38](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h27m38s) So you can in that switch (add new button) decide whether it should show it or not. If you say yes and you have in that view created the correct permissional structure for somebody to create an item, you can control the display of that 'new" button [00:28:02](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h28m02s) with just setting the permission of that users specific group. So if that user is in a group that does not have permission to create new items, for in this example, for preachers or for sermons, then that 'new' button will also not show up. So we have that permissional wrapped around that button's display methods. [00:28:26](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h28m26s)
That is the tabs just looking at the tabs. That's really what we were looking at and then explaining to you how to link other views to it and to other views so that you can have the data displayed inside of each other. [00:28:43](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h28m43s) Basically this feature we have here so the fact that we are busy in preachers and we are able to display the fields that are being used. As you can imagine these fields are linked to preachers from this column here, so we are using a repeatable field structure [00:29:05](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h29m05s) and we are able to connect the field names to this view.
As we were looking at the tabs I have explaining to you how to link other views to it so that you can have the data displayed inside of each other. [00:28:43](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h28m43s) Basically this feature we have here so the fact that we are busy in preachers and we are able to display the fields that are being used. As you can imagine these fields are linked to preachers from this column here, so we are using a repeatable field structure [00:29:05](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h29m05s) and we are able to connect the field names to this view.
Now let me show you how I did that. So I'm going to open the admin view which is the one we looking at. [00:29:32](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h29m32s) I'm going to link views and you see that I have there a 'R' in the pointer and the word field so if you are trying to connect a view from the parent. And in the parent it is stored in 'addfields' that is the database [00:29:54](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h29m54s) column name. So if we go to the database, go to Component Builder, admin views and we scroll, you would see there is addfields and if I open that you see that the way it stores it. It stores the ID, then it stores the list. [00:30:21](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h30m21s) So there's a way in which your repeatable fields are stored by Joomla. and the value that I need to look up is in field. So in the repeatable field called addfields there is a field called 'field'. And it should look for the ID of the fields. So it need to look in addfields [00:30:51](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h30m51s) in the field array for the IDs, that it needs to fetch, and the way you would mapped that in the connect a linked view is you would say that this is a capital 'R' for repeatable fields basically that is the convention to to tell the system it's a repeatable field we looking in [00:31:14](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h31m14s) and inside of the repeatable field we must look in the field array for those ID's and they should mapped to the child's ID. So does that make sense I hope so. Because that's the way it's done. And if that wasn't a repeatable field but an array you would simply say array [00:31:34](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h31m34s) and if the array is just the values themselves you would drop off any pointer to specific value. But if it's an associative array you would just add the name of the associative key that it needs to look in. [00:32:00](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h32m00s) If it's just a normal array without association leave it like that so this would just tell the system it is a array and it needs to look inside of those values for these IDs. So that's sort of explains the linking of an admin view to another admin view. Now getting on with the setting up of fields. [00:32:28](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h32m28s)