Updated 038 Setup Site Edit View in JCB (markdown)

Amigo 2019-07-30 09:46:15 +02:00
parent e6ed5e1a16
commit 594614098f

@ -4,13 +4,13 @@
[00:00:00](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h00m00s) [00:00:00](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h00m00s)
How to add an Admin View to the front end of your site. There can be editing and submission of the front end of this specific Admin View. The public version of JCB is being used to illustrate this, it has this Demo Version in it. First it is compiled and installed to the local Joomla website. Install it, open it. Here is the demo version that is publicly available and it has a Admin View called "Looks". [00:01:07](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h01m07s) If you go to the List View of the Admin View, called 'Looks', there is none. Create 'New'. There is a description box in the New view. A 'More' item, where you can click, and see some custom fields: 'email', 'mobile phone', 'date of birth', 'image', 'website' and the normal Publish, Permission, Structure for the view, and the name field. Now that is what has been referred to as the Admin view. It is this combination of fields working together in one view. How to add an Admin View to the front end of your site. There can be editing and submission of the front end of this specific Admin View. The public version of JCB which contains this Demo Version is being used to illustrate this. First it is compiled and installed to the local Joomla website. Install it, open it. Here is the Demo Version that is publicly available and it has a Admin View called "Looks". [00:01:07](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h01m07s) If you go to the List View of the Admin View, called 'Looks', there is none. Create 'New'. There is a description box in the New view and 'More' item, where you can click, and see some custom fields: 'email', 'mobile phone', 'date of birth', 'image', 'website' and the normal Publish, Permission, Structure for the view, and the name field. Now that is what has been referred to as the Admin view. It is this combination of fields working together in one view.
### How To Add Editing Area ### How To Add Editing Area
[00:01:50](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h01m50s) [00:01:50](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h01m50s)
How to add a editing area, (these three tabs to the front end of the site) that it will function like a form. Who will be allowed to access the form will depend upon the permissions structure. The permission structure controls who can edit and who can add items to a specific Admin view. [00:02:14](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m14s) Currently the public cannot edit this, if an item is created they cannot edit it. There is an item level on permissions. If it is closed then it can be seen there is also a 'Global' control on permissions in 'Options'. The Global control of permissions is also, if you want public to be able to submit to this form, it is necessary to allow them to be able to create.[00:02:46](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m46s) Set it to 'Allow', and the public is allowed to create. Most components has more than one view. This one has only one; it is called 'Look'. Over here('Look create') say allow, and if you want them to edit existing submissions. [00:03:13](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m13s)There is the 'Edit state', 'Edit own', 'Created by', all these things in the global spec, as well as in the local edit of the view. To add a editing area, (these three tabs) to the front end of the site that it will function like a form will be explained. To determine who can be allowed to access the form will depend upon the permissions structure. The permission structure controls who can edit and who can add items to a specific Admin view. [00:02:14](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m14s) Currently the public cannot edit this, if an item is created they cannot edit it. There is an item level on permissions. If it is closed then it can be seen that there is also a 'Global' control on permissions in 'Options'. The Global control of permissions is also, if you want public to be able to submit to this form, it is necessary to allow them to be able to create.[00:02:46](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m46s) Set it to 'Allow', and the public is allowed to create. Most components has more than one view. This one has only one; it is called 'Look'. Over here('Look create') say allow, and if you want them to edit existing submissions. [00:03:13](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m13s)There is the 'Edit state', 'Edit own', 'Created by', all these things in the global spec, as well as in the local edit of the view.
### Two Switches ### Two Switches
@ -32,7 +32,7 @@ Looking at the demo websites folder structure in the code, there is a com_demo f
### Manually Add Links ### Manually Add Links
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. 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')(See video), it may be seen in the Helper Class there is a 'getAction' function.
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. 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.
@ -46,4 +46,4 @@ That is how to add an editable Admin view to the site end of your component.[00:
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. 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 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. 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 permissions structure, and it is necessary to adapt that permissions structure as it is fitting to your project.