From 910336e3b754cace4a05fa347497480602b37091 Mon Sep 17 00:00:00 2001 From: Amigo <49749100+aamigo@users.noreply.github.com> Date: Tue, 25 Jun 2019 13:28:48 +0200 Subject: [PATCH] Updated 038 Setup Site Edit View in JCB (markdown) --- 038-Setup-Site-Edit-View-in-JCB.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/038-Setup-Site-Edit-View-in-JCB.md b/038-Setup-Site-Edit-View-in-JCB.md index d24924a..8224585 100644 --- a/038-Setup-Site-Edit-View-in-JCB.md +++ b/038-Setup-Site-Edit-View-in-JCB.md @@ -20,15 +20,16 @@ We are in the demo component. I'm going to go back to JCB and I'm going to flip Now let's go look at the code. Looking at the demo websites folder structure, we are going to components. We'll see that there is a com_demo folder. [00:06:19](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m19s) We will see there is the models as well as the controllers as well as the views. This is the view that was dynamically generated by JCB. The view, the model and the controller are called look. You can open (controller look.php) to see what was the code that was written. [00:06:49](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m49s) You can see it looks very similar to the admin area except that it's been slightly modified for your front end and it's requirements. As you can see we were adding some CSS classes and JavaScript from the back end. Here is the model, [00:07:16](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h07m16s) getItem, getForm, and the controller. We are showing you the code what was created. The fact that this was created, doesn't mean that there is a set of links that you can click and edit the forms which was submitted or that there is a link to create any. These things is what you need to do manually. [00:07:51](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h07m51s) authores + ### Manually Add Links -Let's show you some of that. There is two views called under site views, one is called looks and other one is called looking. As you can remember the one we looked at here, which I set was automatically generate is called look, so that one isn't showing because it was a tick box that created this whole view model and controller. You don't need to build the look view again. [00:08:21](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m21s) You need to get links to it. In looks we are using a Dynamic Gets, and in looking. Let's go to the Dynamic Gets page. There is one called looks and looking. Let's go to the looks Dynamic Gets. It got a custom script area were we're asking whether the items are set whether there are items. Then we looping through them, and during the looping process we determine by $canDo script, [00:09:10](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m10s) you will see in the helper class there's a getAction function. +Let's show you some of that. There is two views called under site views, one is called looks and other one is called looking. As you can remember the one we looked at here, which I set was automatically generate is called look, so that one isn't showing because it was a tick box that created this whole view model and controller. You don't need to build the look view again. [00:08:21](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m21s) You need to get links to it. In looks we are using a Dynamic Gets, and in looking. Let's go to the Dynamic Gets page. There is one called looks and looking. Let's go to the looks Dynamic Gets. It got a custom script area were we're asking whether the items are set whether there are items. Then we looping through them, and during the looping process we determine by $canDo script, [00:09:10](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m10s) you will see in the helper class there's a getAction function. -The getAction function asks whether look item, where the current user has the edit option to the specific look item. If it does it in this little script, it builds an edit look button. And dynamically adds that to the edit link, which is coupled to the item, and then continues on. It dynamically generates the button for edit in the dynamic get. [00:09:48](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m48s) You could have done that anywhere. I decided to do it here, because then it gets added to the model, which is more where your logic, for lots of your data structure should be placed. If you go back to the site views, open the looks site view. You will see that we got the main get set as looks. If you scroll down, [00:10:25](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m25s) in this area we are looping through the look items, and echoing the edit link after the description. That means the link that we built in the Dynamic Get which is the button, will either be empty and therefore show nothing. If the user doesn't have the permission to edit it, or it will show a button. [00:11:04](https://Basically www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m04s) As I look at this I haven't added a link for creating new looks. The same would be required to do that. +The getAction function asks whether look item, where the current user has the edit option to the specific look item. If it does it in this little script, it builds an edit look button. And dynamically adds that to the edit link, which is coupled to the item, and then continues on. It dynamically generates the button for edit in the dynamic get. [00:09:48](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m48s) You could have done that anywhere. I decided to do it here, because then it gets added to the model, which is more where your logic, for lots of your data structure should be placed. If you go back to the site views, open the looks site view. You will see that we got the main get set as looks. If you scroll down, [00:10:25](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m25s) in this area we are looping through the look items, and echoing the edit link after the description. That means the link that we built in the Dynamic Get which is the button, will either be empty and therefore show nothing. If the user doesn't have the permission to edit it, or it will show a button. [00:11:04](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m04s) As I look at this I haven't added a link for creating new looks. The same would be required to do that. * ### Add A Button To Create New Looks -You could use the same button script, copy that. Here before the table, you could [00:11:29](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m29s) add a button to create new looks. All you would need to change is this link here ((index_php?option_com_[[[Component]]])) that it will have an id to zero. It will create a new look. That's a quick tutorial on how to add an editable [00:11:53](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m53s) admin view to the site end of your component. Then link it into your side view, that you can click on a button and edit a specific id view or create more. Then control that with this getAction helper class method, which gives you whether it can be edited. You can go look at this helper class in the code. [00:12:23](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m23s) +You could use the same button script, copy that. Here before the table, you could [00:11:29](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m29s) add a button to create new looks. All you would need to change is this link here ((index_php?option_com_"Component") that it will have an id to zero. It will create a new look. That's a quick tutorial on how to add an editable [00:11:53](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m53s) admin view to the site end of your component. Then link it into your side view, that you can click on a button and edit a specific id view or create more. Then control that with this getAction helper class method, which gives you whether it can be edited. You can go look at this helper class in the code. [00:12:23](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m23s) Let me just quickly open that for you. Here in the code, in helpers, we open demo.php. We scroll down until we get the method called getAction. [00:12:50](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m50s) Around 540 depends on how much the customer scripting there is been added. You can go through this logic to see that we are dealing with a number of concepts and trying to determine the permission to edit own and to create. It all gets stored and gives back to you [00:13:17](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m17s) in the result set. You could also echo out the result, var dump or something in the look to see exactly what is the result that you get from that structure.