diff --git a/038-Setup-Site-Edit-View-in-JCB.md b/038-Setup-Site-Edit-View-in-JCB.md index 170f2a9..b3b6ef0 100644 --- a/038-Setup-Site-Edit-View-in-JCB.md +++ b/038-Setup-Site-Edit-View-in-JCB.md @@ -34,7 +34,7 @@ Looking at the demo websites folder structure in the code, there is a com_demo f Under site views there are two 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 generated is called 'Look', so that one is not showing because it was a tick box that created this whole View model and Controller. It is not necessary to build the 'Look' view again but you need to get links to it.[00:08:21](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m21s) In 'Looks' a Dynamic Gets is used, as well as in 'Looking'. Open the Dynamic Get page. There is one called 'Looks' and 'Looking'. Go to the Looks Dynamic Get. It got a custom script area were it is asked whether the items are set or whether there are items. [00:09:10](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m10s) Then loop through them('$cando'), it may be seen in the Helper Class there is a 'getAction' function. -The 'getAction' function asks whether the current user has the edit option to the specific 'look' item. If it does, it builds in this little script 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) It could have been done anywhere. I decided to do it here, because then it gets added to the model, which is more where your logic, for lots of the data structure should be placed. Go back to the Site Views, open the 'Looks' Site View. It may be seen that the 'Main Get' is set as 'Looks'. If you scroll down, in this area(See video) we are looping through the 'Look' items, and echoing the edit link after the description.[00:10:25](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m25s) That means the link that has been built in the Dynamic Get which is the button, it will either be empty and therefore show nothing. If the user does not 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) A link has not been added for creating 'New Looks' and the same would be required to do that. +The 'getAction' function inquires whether the current user has the edit option to the specific 'look' item. If it does, it builds in this little script 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) It could have been done anywhere. I decided to do it here, because then it gets added to the model, which is more where your logic, for lots of the data structure should be placed. Go back to the Site Views, open the 'Looks' Site View. It may be seen that the 'Main Get' is set as 'Looks'. If you scroll down, in this area(See video) we are looping through the 'Look' items, and echoing the edit link after the description.[00:10:25](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m25s) That means the link that has been built in the Dynamic Get which is the button, it will either be empty and therefore show nothing. If the user does not 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) A link has not been added for creating 'New Looks' and the same would be required to do that. * ### Add A Button To Create New Looks @@ -42,10 +42,8 @@ The 'getAction' function asks whether the current user has the edit option to th The same button script may be used, copy that. Here before the table, a button could be added to create 'New Looks'. All that 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 is how to add an editable Admin view to the site end of your component.[00:11:53](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m53s) Then link it into your Site 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 indicates 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) +That is how to add an editable Admin view to the site end of your component.[00:11:53](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m53s) Then link it into your Site 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 indicates whether it can be edited. Look at this Helper class in the code. [00:12:23](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m23s) -For example: In the code, in Helpers, open 'demo.php' then scroll down to the method called 'getAction'. [00:12:50](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m50s) 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 it back in the result set. [00:13:17](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m17s) You could also 'echo' out the result, 'var dump' or something in the 'Look' to see exactly what is the result from that structure. +For example: In the code, in 'Helpers', open 'demo.php' then scroll down to the method called 'getAction'. [00:12:50](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m50s) You can go through this logic to see that here are dealt with a number of concepts and we are trying to determine the permission to edit 'own' and to 'create'. It all gets stored and gives it back in the result set. [00:13:17](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m17s) You could also 'echo' out the result, 'var dump' or something in the 'Look' to see exactly what is the result from that structure. -If we go back to the 'Looks' view and open that model. [00:13:42](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m42s) It will be seen that the custom scripting that creates the button, gets added from JCB(see video). You could come in here, and add a 'var_dump';exit; and take '$cando' [00:14:06](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m06s) and login as any kind of user on the site, then when the page is loaded, it should display the '$cando' list of that specific user group.<<<<<<< - -<<<<<<<<<<<<< Also keep in mind that here is the 'Authorise' setting that is applicable to the Looks Site View and is also controlled in the permission structure. [00:14:33](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m33s) There's a lot of permissions automatically being added to components build in JCB. You need to always keep that in mind. It might look like things don't work while it works very well. You just haven't kept in mind that there is a permission structure, and that you need to adapt that permission on structure as it is fitting to your project. \ No newline at end of file +If we go back to the 'Looks' view and open that model. [00:13:42](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m42s) It will be seen that the custom scripting that creates the button, gets added from JCB(see video). You could add a 'var_dump';exit; and take '$cando' [00:14:06](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m06s) and login as any kind of user on the site, then when the page is loaded, it should display the '$cando' list of that specific user group. Also keep in mind that here is the 'Authorise' setting that is applicable to the Looks Site View and is also controlled in the permission structure. [00:14:33](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m33s) Always keep in mind that there are a lot of permissions automatically being added to components build in JCB. If it appear that things does not function properly, it may be that it had not been kept in mind that there is a permission structure, and it is necessary to adapt that permissions structure as it is fitting to your project. \ No newline at end of file